Files
turso/testing/values.test
Glauber Costa cbdd5c5fc7 improve handling of double quotes
I ended up hitting #1974 today and wanted to fix it. I worked with
Claude to generate a more comprehensive set of queries that could fail
aside from just the insert query described in the issue. He got most of
them right - lots of cases were indeed failing. The ones that were
gibberish, he told me I was absolutely right for pointing out they were
bad.

But alas. With the test cases generated, we can work on fixing it. The
place where the assertion was hit, all we need to do there is return
true (but we assert that this is indeed a string literal, it shouldn't
be anything else at this point).

There are then just a couple of places where we need to make sure we
handle double quotes correctly. We already tested for single quotes in a
couple of places, but never for double quotes.

There is one funny corner case where you can just select "col" from tbl,
and if there is no column "col" on the table, that is treated as a
string literal. We handle that too.

Fixes #1974
2025-07-18 10:39:02 -05:00

51 lines
1.2 KiB
Tcl
Executable File

#!/usr/bin/env tclsh
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_execsql_test values-1 {
values(1, 2);
} {1|2};
do_execsql_test values-2 {
values(1, 2), (3, 4);
} {1|2
3|4};
do_execsql_test values-3 {
values(1+1, 2*3);
} {2|6};
do_execsql_test values-in-from {
select * from (values(3, 4, 5), (5, 6, 7), (8, 9, 10));
} {3|4|5
5|6|7
8|9|10};
do_execsql_test values-in-join {
select * from (values(1, 2)) join (values(3, 4), (5, 6));
} {1|2|3|4
1|2|5|6};
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} values-double-quotes-simple {
.dbconfig dqs_dml on
VALUES ("double_quoted_string");
} {double_quoted_string}
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} values-double-quotes-multiple {
.dbconfig dqs_dml on
VALUES ("first", "second"), ("third", "fourth");
} {first|second
third|fourth}
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} values-mixed-quotes {
.dbconfig dqs_dml on
VALUES ("double", 'single'), ('single', "double");
} {double|single
single|double}
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} values-double-quotes-subquery {
.dbconfig dqs_dml on
SELECT * FROM (VALUES ("subquery_string"));
} {subquery_string}