mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 18:24:20 +01:00
Merge remote-tracking branch 'upstream/main' into expr-iif
This commit is contained in:
@@ -130,4 +130,35 @@ do_execsql_test group_by_function_expression_ridiculous {
|
||||
|
||||
do_execsql_test group_by_count_star {
|
||||
select u.first_name, count(*) from users u group by u.first_name limit 1;
|
||||
} {Aaron|41}
|
||||
} {Aaron|41}
|
||||
|
||||
do_execsql_test having {
|
||||
select u.first_name, round(avg(u.age)) from users u group by u.first_name having avg(u.age) > 97 order by avg(u.age) desc limit 5;
|
||||
} {Nina|100.0
|
||||
Kurt|99.0
|
||||
Selena|98.0}
|
||||
|
||||
do_execsql_test having_with_binary_cond {
|
||||
select u.first_name, sum(u.age) from users u group by u.first_name having sum(u.age) + 1000 = 9109;
|
||||
} {Robert|8109}
|
||||
|
||||
do_execsql_test having_with_scalar_fn_over_aggregate {
|
||||
select u.first_name, concat(count(1), ' people with this name') from users u group by u.first_name having count(1) > 50 order by count(1) asc limit 5;
|
||||
} {"Angela|51 people with this name
|
||||
Justin|51 people with this name
|
||||
Rachel|52 people with this name
|
||||
Susan|52 people with this name
|
||||
Jeffrey|54 people with this name"}
|
||||
|
||||
do_execsql_test having_with_multiple_conditions {
|
||||
select u.first_name, count(*), round(avg(u.age)) as avg_age
|
||||
from users u
|
||||
group by u.first_name
|
||||
having count(*) > 40 and avg(u.age) > 40
|
||||
order by count(*) desc, avg(u.age) desc
|
||||
limit 5;
|
||||
} {Michael|228|49.0
|
||||
David|165|53.0
|
||||
Robert|159|51.0
|
||||
Jennifer|151|51.0
|
||||
John|145|50.0}
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env tclsh
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/tester.tcl
|
||||
@@ -212,4 +212,38 @@ do_execsql_test join-utilizing-both-seekrowid-and-secondary-index {
|
||||
select u.first_name, p.name from users u join products p on u.id = p.id and u.age > 70;
|
||||
} {Matthew|boots
|
||||
Nicholas|shorts
|
||||
Jamie|hat}
|
||||
Jamie|hat}
|
||||
|
||||
# important difference between regular SELECT * join and a SELECT * USING join is that the join keys are deduplicated
|
||||
# from the result in the USING case.
|
||||
do_execsql_test join-using {
|
||||
select * from users join products using (id) limit 3;
|
||||
} {"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|hat|79.0
|
||||
2|Cindy|Salazar|williamsrebecca@example.com|287-934-1135|75615 Stacey Shore|South Stephanie|NC|85181|37|cap|82.0
|
||||
3|Tommy|Perry|warechristopher@example.org|001-288-554-8139x0276|2896 Paul Fall Apt. 972|Michaelborough|VA|15691|18|shirt|18.0"}
|
||||
|
||||
do_execsql_test join-using-multiple {
|
||||
select u.first_name, u.last_name, p.name from users u join users u2 using(id) join products p using(id) limit 3;
|
||||
} {"Jamie|Foster|hat
|
||||
Cindy|Salazar|cap
|
||||
Tommy|Perry|shirt"}
|
||||
|
||||
# NATURAL JOIN desugars to JOIN USING (common_column1, common_column2...)
|
||||
do_execsql_test join-using {
|
||||
select * from users natural join products limit 3;
|
||||
} {"1|Jamie|Foster|dylan00@example.com|496-522-9493|62375 Johnson Rest Suite 322|West Lauriestad|IL|35865|94|hat|79.0
|
||||
2|Cindy|Salazar|williamsrebecca@example.com|287-934-1135|75615 Stacey Shore|South Stephanie|NC|85181|37|cap|82.0
|
||||
3|Tommy|Perry|warechristopher@example.org|001-288-554-8139x0276|2896 Paul Fall Apt. 972|Michaelborough|VA|15691|18|shirt|18.0"}
|
||||
|
||||
do_execsql_test natural-join-multiple {
|
||||
select u.first_name, u2.last_name, p.name from users u natural join users u2 natural join products p limit 3;
|
||||
} {"Jamie|Foster|hat
|
||||
Cindy|Salazar|cap
|
||||
Tommy|Perry|shirt"}
|
||||
|
||||
# have to be able to join between 1st table and 3rd table as well
|
||||
do_execsql_test natural-join-and-using-join {
|
||||
select u.id, u2.id, p.id from users u natural join products p join users u2 using (first_name) limit 3;
|
||||
} {"1|1|1
|
||||
1|1204|1
|
||||
1|1261|1"}
|
||||
@@ -351,6 +351,10 @@ do_execsql_test length-text {
|
||||
SELECT length('limbo');
|
||||
} {5}
|
||||
|
||||
do_execsql_test lenght-text-utf8-chars {
|
||||
SELECT length('ąłóżźć');
|
||||
} {6}
|
||||
|
||||
do_execsql_test length-integer {
|
||||
SELECT length(12345);
|
||||
} {5}
|
||||
@@ -367,8 +371,32 @@ do_execsql_test length-empty-text {
|
||||
SELECT length('');
|
||||
} {0}
|
||||
|
||||
do_execsql_test length-date-binary-expr {
|
||||
select length(date('now')) = 10;
|
||||
do_execsql_test octet-length-text {
|
||||
SELECT length('limbo');
|
||||
} {5}
|
||||
|
||||
do_execsql_test octet-lenght-text-utf8-chars {
|
||||
SELECT octet_length('ąłóżźć');
|
||||
} {12}
|
||||
|
||||
do_execsql_test octet-length-integer {
|
||||
SELECT octet_length(12345);
|
||||
} {5}
|
||||
|
||||
do_execsql_test octet-length-float {
|
||||
SELECT octet_length(123.456);
|
||||
} {7}
|
||||
|
||||
do_execsql_test octet-length-null {
|
||||
SELECT octet_length(NULL);
|
||||
} {}
|
||||
|
||||
do_execsql_test octet-length-empty-text {
|
||||
SELECT octet_length('');
|
||||
} {0}
|
||||
|
||||
do_execsql_test octet-length-date-binary-expr {
|
||||
select octet_length(date('now')) = 10;
|
||||
} {1}
|
||||
|
||||
do_execsql_test min-number {
|
||||
|
||||
@@ -57,4 +57,20 @@ do_execsql_test seekrowid {
|
||||
|
||||
do_execsql_test select_parenthesized {
|
||||
select (price + 100) from products limit 1;
|
||||
} {179.0}
|
||||
} {179.0}
|
||||
|
||||
do_execsql_test select_case_base_else {
|
||||
select case when 0 then 'false' when 1 then 'true' else 'null' end;
|
||||
} {true}
|
||||
|
||||
do_execsql_test select_case_noelse_null {
|
||||
select case when 0 then 0 end;
|
||||
} {}
|
||||
|
||||
do_execsql_test select_base_case_else {
|
||||
select case 1 when 0 then 'zero' when 1 then 'one' else 'two' end;
|
||||
} {one}
|
||||
|
||||
do_execsql_test select_base_case_noelse_null {
|
||||
select case 'null else' when 0 then 0 when 1 then 1 end;
|
||||
} {}
|
||||
|
||||
Reference in New Issue
Block a user