Skip to content

Commit d02b6d1

Browse files
committed
Escape all identifier interpolations in the legacy SQLite translator
Apply quote_identifier() (backtick quoting with internal escaping) to all table names, column names, index names, and trigger names that are interpolated into SQL queries, token values, or DDL reconstruction output. Use PDO::quote() for string arguments to pragma functions. Fix two downstream issues caused by the quoting style change: - get_autoincrement_column() regex now accepts both backtick and double-quote delimiters in stored schemas. - CHANGE COLUMN schema parsing now matches both TYPE_SYMBOL (backtick) and TYPE_STRING (double-quote) tokens.
1 parent 535b42a commit d02b6d1

File tree

2 files changed

+75
-51
lines changed

2 files changed

+75
-51
lines changed

tests/WP_SQLite_Translator_Tests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,14 +1170,14 @@ public function testColumnWithOnUpdate() {
11701170
'name' => '___tmp_table_created_at_on_update__',
11711171
'tbl_name' => '_tmp_table',
11721172
'rootpage' => '0',
1173-
'sql' => "CREATE TRIGGER \"___tmp_table_created_at_on_update__\"\n\t\t\tAFTER UPDATE ON \"_tmp_table\"\n\t\t\tFOR EACH ROW\n\t\t\tBEGIN\n\t\t\t UPDATE \"_tmp_table\" SET \"created_at\" = CURRENT_TIMESTAMP WHERE rowid = NEW.rowid;\n\t\t\tEND",
1173+
'sql' => "CREATE TRIGGER `___tmp_table_created_at_on_update__`\n\t\t\tAFTER UPDATE ON `_tmp_table`\n\t\t\tFOR EACH ROW\n\t\t\tBEGIN\n\t\t\t UPDATE `_tmp_table` SET `created_at` = CURRENT_TIMESTAMP WHERE rowid = NEW.rowid;\n\t\t\tEND",
11741174
),
11751175
(object) array(
11761176
'type' => 'trigger',
11771177
'name' => '___tmp_table_updated_at_on_update__',
11781178
'tbl_name' => '_tmp_table',
11791179
'rootpage' => '0',
1180-
'sql' => "CREATE TRIGGER \"___tmp_table_updated_at_on_update__\"\n\t\t\tAFTER UPDATE ON \"_tmp_table\"\n\t\t\tFOR EACH ROW\n\t\t\tBEGIN\n\t\t\t UPDATE \"_tmp_table\" SET \"updated_at\" = CURRENT_TIMESTAMP WHERE rowid = NEW.rowid;\n\t\t\tEND",
1180+
'sql' => "CREATE TRIGGER `___tmp_table_updated_at_on_update__`\n\t\t\tAFTER UPDATE ON `_tmp_table`\n\t\t\tFOR EACH ROW\n\t\t\tBEGIN\n\t\t\t UPDATE `_tmp_table` SET `updated_at` = CURRENT_TIMESTAMP WHERE rowid = NEW.rowid;\n\t\t\tEND",
11811181
),
11821182
),
11831183
$results

0 commit comments

Comments
 (0)