@@ -472,3 +472,99 @@ foreach {operator} {
472
472
# NULL comparison AND id=1
473
473
do_execsql_test where-binary-one-operand-null-and-$operator " select first_name from users where first_name $operator NULL AND id = 1" {}
474
474
}
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