Skip to content

Commit 069f1ef

Browse files
committed
Add a test for the reason to use backtick identifier escaping
1 parent bbe6470 commit 069f1ef

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/WP_SQLite_Driver_Tests.php

+19
Original file line numberDiff line numberDiff line change
@@ -3665,4 +3665,23 @@ public function testColumnDefaults(): void {
36653665
$result[0]->{'Create Table'}
36663666
);
36673667
}
3668+
3669+
public function testSelectNonExistentColumn(): void {
3670+
$this->assertQuery(
3671+
'CREATE TABLE t (id INT)'
3672+
);
3673+
3674+
/*
3675+
* Here, we're basically testing that identifiers are escaped using
3676+
* backticks instead of double quotes. In SQLite, double quotes may
3677+
* fallback to a string literal and thus produce no error.
3678+
*
3679+
* See:
3680+
* https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
3681+
*/
3682+
$this->assertQuery(
3683+
'SELECT non_existent_column FROM t LIMIT 0',
3684+
'no such column: non_existent_column'
3685+
);
3686+
}
36683687
}

0 commit comments

Comments
 (0)