Skip to content

Commit 7d07d3e

Browse files
committed
Make instance FromField Char compatible with bpchar
Closes #210
1 parent bf134aa commit 7d07d3e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Database/PostgreSQL/Simple/FromField.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ instance FromField Bool where
298298
| bs == Just "f" = pure False
299299
| otherwise = returnError ConversionFailed f ""
300300

301-
-- | \"char\"
301+
-- | \"char\", bpchar
302302
instance FromField Char where
303303
fromField f bs =
304-
if typeOid f /= $(inlineTypoid TI.char)
305-
then returnError Incompatible f ""
306-
else case bs of
304+
if $(mkCompats [TI.char,TI.bpchar]) (typeOid f)
305+
then case bs of
307306
Nothing -> returnError UnexpectedNull f ""
308307
Just bs -> if B.length bs /= 1
309308
then returnError ConversionFailed f "length not 1"
310309
else return $! (B.head bs)
310+
else returnError Incompatible f ""
311311

312312
-- | int2
313313
instance FromField Int16 where

0 commit comments

Comments
 (0)