Fix negative integer decoding
Use Int and Word instead of Int64 and Word64 consistently
This commit is contained in:
@@ -132,6 +132,15 @@ spec = do
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS int" [AnInt $ (2 :: Int) ^ (48 :: Int)]
|
||||
|
||||
it "Decodes smallint -42" $ \conn -> do
|
||||
shouldFetch conn "SELECT -42::SMALLINT AS int" [AnInt (-42)]
|
||||
|
||||
it "Decodes integer -42" $ \conn -> do
|
||||
shouldFetch conn "SELECT -42::INTEGER AS int" [AnInt (-42)]
|
||||
|
||||
it "Decodes bigint -42" $ \conn -> do
|
||||
shouldFetch conn "SELECT -42::BIGINT AS int" [AnInt (-42)]
|
||||
|
||||
describe "FromField Integer" $ do
|
||||
it "Decodes smallint" $ \conn -> do
|
||||
shouldFetch conn "SELECT 42::SMALLINT AS integer" [AnInteger 42]
|
||||
@@ -142,6 +151,9 @@ spec = do
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS integer" [AnInteger $ (2 :: Integer) ^ (48 :: Integer)]
|
||||
|
||||
it "Decodes -42" $ \conn -> do
|
||||
shouldFetch conn "SELECT -42 AS integer" [AnInteger (-42)]
|
||||
|
||||
describe "FromField Word" $ do
|
||||
it "Decodes smallint" $ \conn -> do
|
||||
shouldFetch conn "SELECT 42::SMALLINT AS word" [AWord 42]
|
||||
@@ -152,6 +164,12 @@ spec = do
|
||||
it "Decodes bigint" $ \conn -> do
|
||||
shouldFetch conn "SELECT pow(2, 48)::BIGINT AS word" [AWord $ (2 :: Word) ^ (48 :: Word)]
|
||||
|
||||
it "Decodes negative one as 2^64-1" $ \conn -> do
|
||||
shouldFetch conn "SELECT -1::BIGINT AS word" [AWord maxBound]
|
||||
|
||||
it "Decodes integer negative one as 2^32-1" $ \conn -> do
|
||||
shouldFetch conn "SELECT -1::INTEGER AS word" [AWord $ (2 :: Word) ^ (32 :: Word) - 1]
|
||||
|
||||
describe "FromField ByteString" $ do
|
||||
it "Decodes bytea" $ \conn -> do
|
||||
shouldFetch conn "SELECT 'Hello, World!'::BYTEA AS bytestring" [AByteString "Hello, World!"]
|
||||
|
||||
Reference in New Issue
Block a user