Add FromField Word
This commit is contained in:
@@ -24,6 +24,12 @@ newtype AnInteger = AnInteger
|
||||
|
||||
instance FromRow AnInteger where
|
||||
|
||||
newtype AWord = AWord
|
||||
{ word :: Word
|
||||
} deriving (Eq, Generic, Show)
|
||||
|
||||
instance FromRow AWord where
|
||||
|
||||
newtype AText = AText
|
||||
{ text :: Text
|
||||
} deriving (Eq, Generic, Show)
|
||||
@@ -90,6 +96,16 @@ spec = do
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS integer" [AnInteger $ (2 :: Integer) ^ (48 :: Integer)]
|
||||
|
||||
describe "FromField Word" $ do
|
||||
it "Decodes smallint" $ \conn -> do
|
||||
shouldFetch conn "SELECT 42::SMALLINT AS word" [AWord 42]
|
||||
|
||||
it "Decodes integer" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 20)::INTEGER AS word" [AWord $ (2 :: Word) ^ (20 :: Word)]
|
||||
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS word" [AWord $ (2 :: Word) ^ (48 :: Word)]
|
||||
|
||||
describe "FromField Text" $ do
|
||||
it "Decodes text" $ \conn -> do
|
||||
shouldFetch conn "SELECT 'Hello, World!'::TEXT AS text" [AText "Hello, World!"]
|
||||
|
||||
Reference in New Issue
Block a user