Skip to content

Commit c7949a6

Browse files
committed
Add more TCL tests for exprs in select/where positions
1 parent 33e0fe9 commit c7949a6

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-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

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

0 commit comments

Comments
 (0)