File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,13 @@ instance isSqlValueMaybe :: (IsSqlValue a) => IsSqlValue (Maybe a)
195195```
196196
197197
198+ #### ` isSqlValueArray `
199+
200+ ``` purescript
201+ instance isSqlValueArray :: (IsSqlValue a) => IsSqlValue (Array a)
202+ ```
203+
204+
198205
199206## Module Database.Postgres.Transaction
200207
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ instance isSqlValueInt :: IsSqlValue Int where
3131instance isSqlValueMaybe :: (IsSqlValue a ) => IsSqlValue (Maybe a ) where
3232 toSql = unsafeCoerce <<< toNullable <<< (toSql <$> _)
3333
34+ instance isSqlValueArray :: (IsSqlValue a ) => IsSqlValue (Array a ) where
35+ toSql = unsafeCoerce <<< map toSql
36+
3437instance isSqlValueDateTime :: IsSqlValue DateTime where
3538 toSql = toSql <<< format
3639 where
Original file line number Diff line number Diff line change @@ -128,6 +128,17 @@ main = run [consoleReporter] do
128128 ) dt
129129 liftEff $ end pool
130130
131+ describe " sql arrays as parameters" $
132+ it " can be passed as a SqlValue" do
133+ pool <- liftEff $ mkPool connectionInfo
134+ withClient pool \c -> do
135+ execute_ (Query " delete from artist" ) c
136+ execute_ (Query " insert into artist values ('Zed Leppelin', 1967)" ) c
137+ execute_ (Query " insert into artist values ('Led Zeppelin', 1968)" ) c
138+ execute_ (Query " insert into artist values ('Deep Purple', 1969)" ) c
139+ artists <- query (Query " select * from artist where year = any ($1)" :: Query Artist ) [toSql [1968 , 1969 ]] c
140+ length artists `shouldEqual` 2
141+ liftEff $ end pool
131142
132143 describe " transactions" do
133144 it " does not commit after an error inside a transation" do
You can’t perform that action at this time.
0 commit comments