You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ihp/Test/Test/QueryBuilderSpec.hs
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -169,6 +169,13 @@ tests = do
169
169
170
170
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE posts.external_url IS NOT NULL")
171
171
172
+
it "should not consume a parameter slot for IS NOT NULL"do
173
+
let theQuery = query @Post
174
+
|> filterWhereNot (#externalUrl, Nothing)
175
+
|> filterWhere (#title, "Test"::Text)
176
+
177
+
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE (posts.external_url IS NOT NULL) AND (posts.title = $1)")
178
+
172
179
describe "filterWhereIn"do
173
180
it "should use = ANY for IN clause"do
174
181
let theValues :: [Text] = ["first", "second"]
@@ -206,6 +213,14 @@ tests = do
206
213
207
214
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE posts.category_id IS NULL")
208
215
216
+
it "should not consume a parameter slot for IS NULL in mixed list"do
217
+
let theValues :: [MaybeUUID] = ["44dcf2cf-a79d-4caf-a2ea-427838ba3574", Nothing]
218
+
let theQuery = query @Post
219
+
|> filterWhereIn (#categoryId, theValues)
220
+
|> filterWhere (#title, "Test"::Text)
221
+
222
+
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE ((posts.category_id = ANY ($1)) OR (posts.category_id IS NULL)) AND (posts.title = $2)")
223
+
209
224
describe "filterWhereInCaseInsensitive"do
210
225
it "should produce a SQL with a WHERE LOWER() condition"do
211
226
let theQuery = query @Post
@@ -250,6 +265,14 @@ tests = do
250
265
251
266
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE posts.category_id IS NOT NULL")
252
267
268
+
it "should not consume a parameter slot for IS NOT NULL in mixed list"do
269
+
let theValues :: [MaybeUUID] = ["44dcf2cf-a79d-4caf-a2ea-427838ba3574", Nothing]
270
+
let theQuery = query @Post
271
+
|> filterWhereNotIn (#categoryId, theValues)
272
+
|> filterWhere (#title, "Test"::Text)
273
+
274
+
(toSQL theQuery) `shouldBe` ("SELECT "<> postColumns <>" FROM posts WHERE ((posts.category_id <> ALL ($1)) AND (posts.category_id IS NOT NULL)) AND (posts.title = $2)")
275
+
253
276
describe "filterWhereIn with JobStatus"do
254
277
it "should use = ANY for JobStatus IN clause"do
255
278
let jobColumns ="background_jobs.id, background_jobs.status"
0 commit comments