Skip to content

Commit 5d0b04f

Browse files
authored
Merge pull request #4 from bung87/refactor3
add cross join test cases
2 parents 0e42c4e + 90a3324 commit 5d0b04f

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/sqlbuilderpkg/utils.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type
1919
INNER
2020
LEFT
2121
RIGHT
22+
CROSS
2223
FULL
2324

2425
SQLQueryType* = enum

tests/select/test_select.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ suite "test sqlSelect - joins":
191191
)
192192
check querycompare(test, sql("SELECT id, name FROM tasks AS t INNER JOIN projects ON (projects.id = t.project_id AND projects.status = 1) WHERE id = ? "))
193193

194+
test "CROSS JOIN":
195+
var test: SqlQuery
196+
197+
test = sqlSelect(
198+
table = "a",
199+
select = @["id"],
200+
joinargs = @[(table: "b", tableAs: "", on: @["a.id = b.id"])],
201+
jointype = CROSS,
202+
useDeleteMarker = false
203+
)
204+
check querycompare(test, sql("SELECT id FROM a CROSS JOIN b ON (a.id = b.id)"))
205+
194206

195207

196208
suite "test sqlSelect - deletemarkers / softdelete":

tests/select/test_select_const.nim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ suite "test sqlSelectConst - joins":
247247
)
248248
check querycompare(test, sql("SELECT id, name FROM tasks AS t INNER JOIN projects ON (projects.id = t.project_id AND projects.status = 1) WHERE id = ? "))
249249

250+
test "CROSS JOIN":
251+
var test: SqlQuery
252+
253+
test = sqlSelectConst(
254+
table = "a",
255+
select = ["id"],
256+
where = [],
257+
joinargs = [(table: "b", tableAs: "", on: @["a.id = b.id"])],
258+
jointype = CROSS,
259+
)
260+
check querycompare(test, sql("SELECT id FROM a CROSS JOIN b ON (a.id = b.id)"))
250261

251262
test "JOIN #1":
252263
var test: SqlQuery

0 commit comments

Comments
 (0)