Skip to content

Commit

Permalink
Add a test for the reason to use backtick identifier escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
JanJakes committed Jan 30, 2025
1 parent bbe6470 commit 069f1ef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/WP_SQLite_Driver_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -3665,4 +3665,23 @@ public function testColumnDefaults(): void {
$result[0]->{'Create Table'}
);
}

public function testSelectNonExistentColumn(): void {
$this->assertQuery(
'CREATE TABLE t (id INT)'
);

/*
* Here, we're basically testing that identifiers are escaped using
* backticks instead of double quotes. In SQLite, double quotes may
* fallback to a string literal and thus produce no error.
*
* See:
* https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
*/
$this->assertQuery(
'SELECT non_existent_column FROM t LIMIT 0',
'no such column: non_existent_column'
);
}
}

0 comments on commit 069f1ef

Please sign in to comment.