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)
195
195
```
196
196
197
197
198
+ #### ` isSqlValueArray `
199
+
200
+ ``` purescript
201
+ instance isSqlValueArray :: (IsSqlValue a) => IsSqlValue (Array a)
202
+ ```
203
+
204
+
198
205
199
206
## Module Database.Postgres.Transaction
200
207
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ instance isSqlValueInt :: IsSqlValue Int where
31
31
instance isSqlValueMaybe :: (IsSqlValue a ) => IsSqlValue (Maybe a ) where
32
32
toSql = unsafeCoerce <<< toNullable <<< (toSql <$> _)
33
33
34
+ instance isSqlValueArray :: (IsSqlValue a ) => IsSqlValue (Array a ) where
35
+ toSql = unsafeCoerce <<< map toSql
36
+
34
37
instance isSqlValueDateTime :: IsSqlValue DateTime where
35
38
toSql = toSql <<< format
36
39
where
Original file line number Diff line number Diff line change @@ -128,6 +128,17 @@ main = run [consoleReporter] do
128
128
) dt
129
129
liftEff $ end pool
130
130
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
131
142
132
143
describe " transactions" do
133
144
it " does not commit after an error inside a transation" do
You can’t perform that action at this time.
0 commit comments