Skip to content

Commit

Permalink
A couple more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasTJdev committed Dec 21, 2023
1 parent 6a1462c commit 1ffa820
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/select/test_select.nim
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,45 @@ suite "test sqlSelect":

suite "test sqlSelect - joins":

test "LEFT JOIN [no values] using empty []":
var test: SqlQuery

test = sqlSelect(
table = "tasks",
tableAs = "t",
select = @["id", "name"],
where = @["id ="],
joinargs = @[],
useDeleteMarker = false
)
check querycompare(test, sql("SELECT id, name FROM tasks AS t WHERE id = ? "))

test "LEFT JOIN [no values] using varargs instead of seq":
var test: SqlQuery

test = sqlSelect(
table = "tasks",
tableAs = "t",
select = ["id", "name"],
where = ["id ="],
joinargs = [],
useDeleteMarker = false
)
check querycompare(test, sql("SELECT id, name FROM tasks AS t WHERE id = ? "))

test "LEFT JOIN using AS values with varargs":
var test: SqlQuery

test = sqlSelect(
table = "tasks",
tableAs = "t",
select = ["id", "name"],
where = ["id ="],
joinargs = [(table: "projects", tableAs: "p", on: @["p.id = t.project_id", "p.status = 1"])],
useDeleteMarker = false
)
check querycompare(test, sql("SELECT id, name FROM tasks AS t LEFT JOIN projects AS p ON (p.id = t.project_id AND p.status = 1) WHERE id = ? "))

test "LEFT JOIN using AS values":
var test: SqlQuery

Expand Down

0 comments on commit 1ffa820

Please sign in to comment.