-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created TCL tests for select queries with offset
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |