Skip to content

Commit 423a0ad

Browse files
committed
Add more TCL tests for exprs in select/where positions
1 parent 5e76656 commit 423a0ad

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

testing/select.test

+9
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,12 @@ do_execsql_test select_bin_shl {
151151
-997623670|-1995247340|-1021566638080|-1071190259091374080
152152
997623670|1995247340|1021566638080|1071190259091374080
153153
-997623670|-1995247340|-1021566638080|-1071190259091374080}
154+
155+
# Test LIKE in SELECT position
156+
do_execsql_test select-like-expression {
157+
select 'bar' like 'bar%'
158+
} {1}
159+
160+
do_execsql_test select-not-like-expression {
161+
select 'bar' not like 'bar%'
162+
} {0}

testing/where.test

+92
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,95 @@ foreach {operator} {
472472
# NULL comparison AND id=1
473473
do_execsql_test where-binary-one-operand-null-and-$operator "select first_name from users where first_name $operator NULL AND id = 1" {}
474474
}
475+
476+
# Test literals in WHERE clause
477+
do_execsql_test where-literal-string {
478+
select count(*) from users where 'yes';
479+
} {0}
480+
481+
# FIXME: should return 0
482+
#do_execsql_test where-literal-number {
483+
# select count(*) from users where x'DEADBEEF';
484+
#} {0}
485+
486+
# Test CAST in WHERE clause
487+
do_execsql_test where-cast-string-to-int {
488+
select count(*) from users where cast('1' as integer);
489+
} {10000}
490+
491+
do_execsql_test where-cast-float-to-int {
492+
select count(*) from users where cast('0' as integer);
493+
} {0}
494+
495+
# Test FunctionCall in WHERE clause
496+
do_execsql_test where-function-length {
497+
select count(*) from users where length(first_name);
498+
} {10000}
499+
500+
# Test CASE in WHERE clause
501+
do_execsql_test where-case-simple {
502+
select count(*) from users where
503+
case when age > 0 then 1 else 0 end;
504+
} {10000}
505+
506+
do_execsql_test where-case-searched {
507+
select count(*) from users where
508+
case age
509+
when 0 then 0
510+
else 1
511+
end;
512+
} {10000}
513+
514+
# Test unary operators in WHERE clause
515+
do_execsql_test where-unary-not {
516+
select count(*) from users where not (id = 1);
517+
} {9999}
518+
519+
do_execsql_test where-unary-plus {
520+
select count(*) from users where +1;
521+
} {10000}
522+
523+
do_execsql_test where-unary-minus {
524+
select count(*) from users where -1;
525+
} {10000}
526+
527+
do_execsql_test where-unary-bitnot {
528+
select count(*) from users where ~1;
529+
} {10000}
530+
531+
# Test binary math operators in WHERE clause
532+
do_execsql_test where-binary-add {
533+
select count(*) from users where 1 + 1;
534+
} {10000}
535+
536+
do_execsql_test where-binary-subtract {
537+
select count(*) from users where 2 - 1;
538+
} {10000}
539+
540+
do_execsql_test where-binary-multiply {
541+
select count(*) from users where 2 * 1;
542+
} {10000}
543+
544+
do_execsql_test where-binary-divide {
545+
select count(*) from users where 2 / 2;
546+
} {10000}
547+
548+
do_execsql_test where-binary-modulo {
549+
select count(*) from users where 3 % 2;
550+
} {10000}
551+
552+
do_execsql_test where-binary-shift-left {
553+
select count(*) from users where 1 << 1;
554+
} {10000}
555+
556+
do_execsql_test where-binary-shift-right {
557+
select count(*) from users where 2 >> 1;
558+
} {10000}
559+
560+
do_execsql_test where-binary-bitwise-and {
561+
select count(*) from users where 3 & 1;
562+
} {10000}
563+
564+
do_execsql_test where-binary-bitwise-or {
565+
select count(*) from users where 2 | 1;
566+
} {10000}

0 commit comments

Comments
 (0)