mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 09:14:24 +01:00
testing: join.test
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
source $testdir/join.test
|
||||
|
||||
do_execsql_test select-const-1 {
|
||||
SELECT 1
|
||||
} {1}
|
||||
@@ -67,15 +69,6 @@ do_execsql_test pragma-cache-size {
|
||||
PRAGMA cache_size
|
||||
} {-2000}
|
||||
|
||||
|
||||
do_execsql_test cross-join {
|
||||
select * from users, products limit 1;
|
||||
} {1|Jamie|Foster|dylan00@example.com|496-522-9493|62375\ Johnson\ Rest\ Suite\ 322|West\ Lauriestad|IL|35865|94|1|hat|79.0}
|
||||
|
||||
do_execsql_test cross-join-specific-columns {
|
||||
select first_name, price from users, products limit 1;
|
||||
} {Jamie|79.0}
|
||||
|
||||
do_execsql_test realify {
|
||||
select price from products limit 1;
|
||||
} {79.0}
|
||||
@@ -153,41 +146,6 @@ do_execsql_test coalesce-from-table-multiple-columns {
|
||||
select coalesce(NULL, age), coalesce(NULL, id) from users where age = 94 limit 1;
|
||||
} {94|1}
|
||||
|
||||
do_execsql_test inner-join-pk {
|
||||
select users.first_name as user_name, products.name as product_name from users join products on users.id = products.id;
|
||||
} {Jamie|hat
|
||||
Cindy|cap
|
||||
Tommy|shirt
|
||||
Jennifer|sweater
|
||||
Edward|sweatshirt
|
||||
Nicholas|shorts
|
||||
Aimee|jeans
|
||||
Rachel|sneakers
|
||||
Matthew|boots
|
||||
Daniel|coat
|
||||
Travis|accessories}
|
||||
|
||||
do_execsql_test inner-join-non-pk-unqualified {
|
||||
select first_name, name from users join products on first_name != name limit 1;
|
||||
} {Jamie|hat}
|
||||
|
||||
do_execsql_test inner-join-non-pk-qualified {
|
||||
select users.first_name as user_name, products.name as product_name from users join products on users.first_name = products.name;
|
||||
} {}
|
||||
|
||||
do_execsql_test inner-join-self {
|
||||
select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 join users as u2 on u1.id = u2.id + 1 limit 1;
|
||||
} {Cindy|Jamie}
|
||||
|
||||
do_execsql_test inner-join-self-with-where {
|
||||
select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 join users as u2 on u1.id = u2.id + 1 where u1.id = 5 limit 1;
|
||||
} {Edward|Jennifer}
|
||||
|
||||
# Uncomment this test when it works. Sqlite3 returns 'Aaron' due to the way it reorders tables in the join based on the where clause.
|
||||
#do_execsql_test inner-join-with-where-2 {
|
||||
# select u.first_name from users u join products as p on u.first_name != p.name where u.last_name = 'Williams' limit 1;
|
||||
#} {Laura} <-- sqlite3 returns 'Aaron'
|
||||
|
||||
do_execsql_test select-add {
|
||||
select u.age + 1 from users u where u.age = 91 limit 1;
|
||||
} {92}
|
||||
|
||||
47
testing/join.test
Executable file
47
testing/join.test
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env tclsh
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_execsql_test cross-join {
|
||||
select * from users, products limit 1;
|
||||
} {1|Jamie|Foster|dylan00@example.com|496-522-9493|62375\ Johnson\ Rest\ Suite\ 322|West\ Lauriestad|IL|35865|94|1|hat|79.0}
|
||||
|
||||
do_execsql_test cross-join-specific-columns {
|
||||
select first_name, price from users, products limit 1;
|
||||
} {Jamie|79.0}
|
||||
|
||||
do_execsql_test inner-join-pk {
|
||||
select users.first_name as user_name, products.name as product_name from users join products on users.id = products.id;
|
||||
} {Jamie|hat
|
||||
Cindy|cap
|
||||
Tommy|shirt
|
||||
Jennifer|sweater
|
||||
Edward|sweatshirt
|
||||
Nicholas|shorts
|
||||
Aimee|jeans
|
||||
Rachel|sneakers
|
||||
Matthew|boots
|
||||
Daniel|coat
|
||||
Travis|accessories}
|
||||
|
||||
do_execsql_test inner-join-non-pk-unqualified {
|
||||
select first_name, name from users join products on first_name != name limit 1;
|
||||
} {Jamie|hat}
|
||||
|
||||
do_execsql_test inner-join-non-pk-qualified {
|
||||
select users.first_name as user_name, products.name as product_name from users join products on users.first_name = products.name;
|
||||
} {}
|
||||
|
||||
do_execsql_test inner-join-self {
|
||||
select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 join users as u2 on u1.id = u2.id + 1 limit 1;
|
||||
} {Cindy|Jamie}
|
||||
|
||||
do_execsql_test inner-join-self-with-where {
|
||||
select u1.first_name as user_name, u2.first_name as neighbor_name from users u1 join users as u2 on u1.id = u2.id + 1 where u1.id = 5 limit 1;
|
||||
} {Edward|Jennifer}
|
||||
|
||||
# Uncomment this test when it works. Sqlite3 returns 'Aaron' due to the way it reorders tables in the join based on the where clause.
|
||||
#do_execsql_test inner-join-with-where-2 {
|
||||
# select u.first_name from users u join products as p on u.first_name != p.name where u.last_name = 'Williams' limit 1;
|
||||
#} {Laura} <-- sqlite3 returns 'Aaron'
|
||||
Reference in New Issue
Block a user