Add tuple decoding into multiple records
This commit is contained in:
@@ -122,6 +122,13 @@ spec = do
|
||||
row <- Opium.fromRow result columnTable 0
|
||||
row `shouldBe` Right (ManyFields "abc" 42 1.0 "test" True)
|
||||
|
||||
it "Decodes multiple records into a tuple" $ \conn -> do
|
||||
Just result <- LibPQ.execParams conn "SELECT 'albus' AS name, 123 AS age, 42 AS only" [] LibPQ.Binary
|
||||
Right columnTable <- Opium.getColumnTable @(Person, Only Int) Proxy result
|
||||
|
||||
row <- Opium.fromRow @(Person, Only Int) result columnTable 0
|
||||
row `shouldBe` Right (Person "albus" 123, Only 42)
|
||||
|
||||
describe "fetch" $ do
|
||||
it "Passes numbered parameters and retrieves a list of rows" $ \conn -> do
|
||||
rows <- Opium.fetch "SELECT ($1 + $2) AS only" (17 :: Int, 25 :: Int) conn
|
||||
|
||||
Reference in New Issue
Block a user