diff --git a/src/Database/PostgreSQL/PQTypes/FromSQL.hs b/src/Database/PostgreSQL/PQTypes/FromSQL.hs index bd9785d..e9eb5f0 100644 --- a/src/Database/PostgreSQL/PQTypes/FromSQL.hs +++ b/src/Database/PostgreSQL/PQTypes/FromSQL.hs @@ -68,6 +68,21 @@ instance FromSQL Double where fromSQL Nothing = unexpectedNULL fromSQL (Just n) = pure . realToFrac $ n +instance FromSQL Word16 where + type PQBase Int32 = CUShort + fromSQL Nothing = unexpectedNULL + fromSQL (Just n) = pure . fromIntegral $ n + +instance FromSQL Word32 where + type PQBase Int32 = CUInt + fromSQL Nothing = unexpectedNULL + fromSQL (Just n) = pure . fromIntegral $ n + +instance FromSQL Word64 where + type PQBase Int32 = CULLong + fromSQL Nothing = unexpectedNULL + fromSQL (Just n) = pure . fromIntegral $ n + -- CHAR instance FromSQL Char where diff --git a/src/Database/PostgreSQL/PQTypes/ToSQL.hs b/src/Database/PostgreSQL/PQTypes/ToSQL.hs index 2269216..3bd244a 100644 --- a/src/Database/PostgreSQL/PQTypes/ToSQL.hs +++ b/src/Database/PostgreSQL/PQTypes/ToSQL.hs @@ -84,6 +84,18 @@ instance ToSQL Double where type PQDest Double = CDouble toSQL n _ = putAsPtr (realToFrac n) +instance ToSQL Word16 where + type PQDest Word16 = CUShort + toSQL n _ = putAsPtr (fromIntegral n) + +instance ToSQL Word32 where + type PQDest Word32 = CUInt + toSQL n _ = putAsPtr (fromIntegral n) + +instance ToSQL Word64 where + type PQDest Word64 = CULLon + toSQL n _ = putAsPtr (fromIntegral n) + -- CHAR instance ToSQL Char where