Permalink
Browse files

Make instance FromField Char compatible with bpchar

Closes #210
  • Loading branch information...
1 parent bf134aa commit 7d07d3e68a132089492e499449e515dd99d8d2fa @lpsmith committed Apr 20, 2017
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/Database/PostgreSQL/Simple/FromField.hs
@@ -298,16 +298,16 @@ instance FromField Bool where
| bs == Just "f" = pure False
| otherwise = returnError ConversionFailed f ""
--- | \"char\"
+-- | \"char\", bpchar
instance FromField Char where
fromField f bs =
- if typeOid f /= $(inlineTypoid TI.char)
- then returnError Incompatible f ""
- else case bs of
+ if $(mkCompats [TI.char,TI.bpchar]) (typeOid f)
+ then case bs of
Nothing -> returnError UnexpectedNull f ""
Just bs -> if B.length bs /= 1
then returnError ConversionFailed f "length not 1"
else return $! (B.head bs)
+ else returnError Incompatible f ""
-- | int2
instance FromField Int16 where

0 comments on commit 7d07d3e

Please sign in to comment.