Skip to content

Commit

Permalink
Created TCL tests for select queries with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
ben594 committed Jan 26, 2025
1 parent 54a6505 commit 847617d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions testing/all.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ source $testdir/where.test
source $testdir/compare.test
source $testdir/changes.test
source $testdir/total-changes.test
source $testdir/offset.test
47 changes: 47 additions & 0 deletions testing/offset.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env tclsh

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_execsql_test select-offset-0 {
SELECT id FROM users ORDER BY id LIMIT 1 OFFSET 0;
} {1}

do_execsql_test select-offset-1 {
SELECT id FROM users ORDER BY id LIMIT 1 OFFSET 1;
} {2}

do_execsql_test select-offset-negative {
SELECT id FROM users ORDER BY id LIMIT 1 OFFSET -1;
} {1}

do_execsql_test select-offset-0-groupby {
SELECT COUNT(*) FROM users GROUP BY STATE ORDER BY STATE LIMIT 5 OFFSET 0;
} {168
166
162
153
166}

do_execsql_test select-offset-1-groupby {
SELECT COUNT(*) FROM users GROUP BY STATE ORDER BY STATE LIMIT 5 OFFSET 1;
} {166
162
153
166
170}

do_execsql_test select-offset-subquery {
SELECT id, first_name, age
FROM (
SELECT id, first_name, age
FROM users
ORDER BY id ASC
LIMIT 5 OFFSET 2
)
ORDER BY id DESC;
} {7|Aimee|24
6|Nicholas|89
5|Edward|15
4|Jennifer|33
3|Tommy|18}

0 comments on commit 847617d

Please sign in to comment.