Add FromField Integer
This commit is contained in:
@@ -18,6 +18,12 @@ newtype AnInt = AnInt
|
||||
|
||||
instance FromRow AnInt where
|
||||
|
||||
newtype AnInteger = AnInteger
|
||||
{ integer :: Integer
|
||||
} deriving (Eq, Generic, Show)
|
||||
|
||||
instance FromRow AnInteger where
|
||||
|
||||
newtype AText = AText
|
||||
{ text :: Text
|
||||
} deriving (Eq, Generic, Show)
|
||||
@@ -72,7 +78,17 @@ spec = do
|
||||
shouldFetch conn "SELECT 42::INTEGER AS int" [AnInt 42]
|
||||
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT 42::BIGINT AS int" [AnInt 42]
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS int" [AnInt $ (2 :: Int) ^ (48 :: Int)]
|
||||
|
||||
describe "FromField Integer" $ do
|
||||
it "Decodes smallint" $ \conn -> do
|
||||
shouldFetch conn "SELECT 42::SMALLINT AS integer" [AnInteger 42]
|
||||
|
||||
it "Decodes integer" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 20)::INTEGER AS integer" [AnInteger $ (2 :: Integer) ^ (20 :: Integer)]
|
||||
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS integer" [AnInteger $ (2 :: Integer) ^ (48 :: Integer)]
|
||||
|
||||
describe "FromField Text" $ do
|
||||
it "Decodes text" $ \conn -> do
|
||||
|
||||
Reference in New Issue
Block a user