Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasTJdev committed Jan 13, 2024
1 parent dbe58da commit 9606803
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/select/test_select.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ suite "test sqlSelect":
check querycompare(test, sql("SELECT t.id, t.name, t.description, t.created, t.updated, t.completed FROM tasks AS t WHERE t.id = ? "))


test "from using AS inline ":
var test: SqlQuery

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



test "WHERE statements: general":
var test: SqlQuery

Expand Down Expand Up @@ -215,6 +228,18 @@ suite "test sqlSelect - joins":
)
check querycompare(test, sql("SELECT id, name FROM tasks AS t LEFT JOIN projects ON (projects.id = t.project_id AND projects.status = 1) WHERE id = ? "))

test "LEFT JOIN (default) from table as inline":
var test: SqlQuery

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


test "INNER JOIN":
var test: SqlQuery
Expand Down

0 comments on commit 9606803

Please sign in to comment.