Skip to content

Commit d77b76e

Browse files
authored
Merge 'string sometimes used as identifier quoting' from Lâm Hoàng Phúc
fix #2886 (comment) 3244885481 Closes #2894
2 parents 36909d4 + 635402f commit d77b76e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

core/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ impl RoundToPrecision for f64 {
5858
}
5959

6060
// https://sqlite.org/lang_keywords.html
61-
const QUOTE_PAIRS: &[(char, char)] = &[('"', '"'), ('[', ']'), ('`', '`')];
61+
const QUOTE_PAIRS: &[(char, char)] = &[
62+
('"', '"'),
63+
('[', ']'),
64+
('`', '`'),
65+
('\'', '\''), // string sometimes used as identifier quoting
66+
];
6267

6368
pub fn normalize_ident(identifier: &str) -> String {
6469
let quote_pair = QUOTE_PAIRS

testing/create_table.test

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@ do_execsql_test_on_specific_db {:memory:} create_table_rowid_unique_regression_t
2020
create table u(x integer unique primary key);
2121
insert into u values (1),(2),(3);
2222
select * from u where x > 2;
23-
} {3}
23+
} {3}
24+
25+
# https://github.com/tursodatabase/turso/issues/2886#issuecomment-3244885481
26+
do_execsql_test_on_specific_db {:memory:} create_table_with_empty_string_name {
27+
create table ''('' INTEGER) strict;
28+
insert into '' values(9);
29+
select * from '';
30+
} {9}

0 commit comments

Comments
 (0)