mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-20 15:35:29 +01:00
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
This commit is contained in:
@@ -409,4 +409,52 @@ if {[info exists ::env(SQLITE_EXEC)] && ($::env(SQLITE_EXEC) eq "scripts/limbo-s
|
||||
INSERT INTO t VALUES (replace(hex(zeroblob(1000)), '00', 'a') || 'h', 8);
|
||||
SELECT COUNT(*) FROM t WHERE x >= replace(hex(zeroblob(100)), '00', 'a');
|
||||
} {8}
|
||||
}
|
||||
}
|
||||
|
||||
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} double-quote-string-literals {
|
||||
.dbconfig dqs_dml on
|
||||
CREATE TABLE test (id INTEGER, name TEXT);
|
||||
INSERT INTO test (id, name) VALUES (1, "Dave");
|
||||
INSERT INTO test (id,name) VALUES (2, 'Alice');
|
||||
SELECT * FROM test ORDER BY id;
|
||||
} {1|Dave
|
||||
2|Alice}
|
||||
|
||||
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} mixed-quote-types {
|
||||
.dbconfig dqs_dml on
|
||||
CREATE TABLE mixed (a TEXT, b TEXT, c TEXT);
|
||||
INSERT INTO mixed (a,b,c) VALUES ("double", 'single', "another");
|
||||
SELECT * FROM mixed;
|
||||
} {double|single|another}
|
||||
|
||||
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} double-quote-regression-original-case {
|
||||
.dbconfig dqs_dml on
|
||||
CREATE TABLE users (
|
||||
id INTEGER,
|
||||
name TEXT,
|
||||
email TEXT
|
||||
);
|
||||
INSERT INTO users (name) values ("Dave");
|
||||
SELECT name FROM users;
|
||||
} {Dave}
|
||||
|
||||
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} double-quote-multiple-rows {
|
||||
.dbconfig dqs_dml on
|
||||
CREATE TABLE items (id INTEGER, description TEXT, category TEXT);
|
||||
INSERT INTO items (id, description, category) VALUES
|
||||
(1, "First_item", "category_a"),
|
||||
(2, 'Second_item', "category_b"),
|
||||
(3, "Third_item", 'category_c');
|
||||
SELECT id, description, category FROM items ORDER BY id;
|
||||
} {1|First_item|category_a
|
||||
2|Second_item|category_b
|
||||
3|Third_item|category_c}
|
||||
|
||||
do_execsql_test_skip_lines_on_specific_db 1 {:memory:} double-quote-inner-quotes-preservation {
|
||||
.dbconfig dqs_dml on
|
||||
CREATE TABLE inner_quotes_test (id INTEGER, content TEXT);
|
||||
INSERT INTO inner_quotes_test VALUES (1, '"foo"');
|
||||
INSERT INTO inner_quotes_test VALUES (2, "'bar'");
|
||||
SELECT id, content FROM inner_quotes_test ORDER BY id;
|
||||
} {1|"foo"
|
||||
2|'bar'}
|
||||
|
||||
Reference in New Issue
Block a user