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: tests/test_sqlquery_generator.nim
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -283,6 +283,31 @@ suite "selectQuery":
283
283
check base.sql =="SELECT actions.id, actions.name, actions.status FROM actions LEFT JOIN project as p ON p.id = actions.project_id WHERE actions.project_id = ? AND actions.is_deleted IS NULL GROUP BY p.name"
284
284
check base.params ==@["123"]
285
285
286
+
test"where field names are normalized to lowercase":
joins =@[("project AS p", LEFTJOIN, @[("p.id", "=", "actions.project_id")])],
291
+
where =@[("Actions.PROJECT_ID", "=", "123")],
292
+
groupBy =@["p.name"],
293
+
)
294
+
check base.sql =="SELECT actions.id, actions.name, actions.status FROM actions LEFT JOIN project as p ON p.id = actions.project_id WHERE actions.project_id = ? AND actions.is_deleted IS NULL GROUP BY p.name"
295
+
check base.params ==@["123"]
296
+
297
+
let grouped =selectQuery(
298
+
table ="actions",
299
+
select =@["actions.id"],
300
+
where =whereAnd(@[
301
+
whereCond("ACTIONS.Status", "=", "active"),
302
+
whereOr(@[
303
+
whereCond("Actions.NAME", "=", "thomas"),
304
+
whereCond("actions.system", "=", "SYS"),
305
+
]),
306
+
]),
307
+
)
308
+
check grouped.sql =="SELECT actions.id FROM actions WHERE (actions.status = ? AND (actions.name = ? OR actions.system = ?)) AND actions.is_deleted IS NULL"
test"table with reserved word column name (method) using strings":
287
312
# Test table with column named "method" which is a reserved word in Nim.
288
313
# When using string literals, use the original SQL column name "method".
@@ -743,7 +768,7 @@ suite "WHERE operators extended":
743
768
where =@[("actions.project_id", "=", "123"), ("LOWER(COALESCE(actions.name, ''))", "=", "test")]
744
769
)
745
770
746
-
check query.sql =="SELECT actions.id, actions.name FROM actions WHERE actions.project_id = ? AND LOWER(COALESCE(actions.name, '')) = ? AND actions.is_deleted IS NULL"
771
+
check query.sql =="SELECT actions.id, actions.name FROM actions WHERE actions.project_id = ? AND lower(coalesce(actions.name, '')) = ? AND actions.is_deleted IS NULL"
0 commit comments