You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve identifier and string escaping in the legacy driver (#321)
Improve escaping consistency in the legacy SQLite translator:
- Use `quote_identifier()` for all identifier interpolations (table
names, column names, index names, trigger names) in SQL queries, token
values, and DDL reconstruction output.
- Use parameterized queries and `PDO::quote()` for all string literals
processed by the translator.
See added tests for more details.
Copy file name to clipboardExpand all lines: tests/WP_SQLite_Translator_Tests.php
+149-2Lines changed: 149 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1170,14 +1170,14 @@ public function testColumnWithOnUpdate() {
1170
1170
'name' => '___tmp_table_created_at_on_update__',
1171
1171
'tbl_name' => '_tmp_table',
1172
1172
'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",
1174
1174
),
1175
1175
(object) array(
1176
1176
'type' => 'trigger',
1177
1177
'name' => '___tmp_table_updated_at_on_update__',
1178
1178
'tbl_name' => '_tmp_table',
1179
1179
'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",
1181
1181
),
1182
1182
),
1183
1183
$results
@@ -3557,4 +3557,151 @@ public function testCreateTableWithDefaultNowFunction() {
3557
3557
$result = $this->assertQuery( 'SELECT * FROM test_now_default WHERE id = 2' );
0 commit comments