[php-src] PR #25173: Implement GH-13597: Add Pdo\Sqlite::ATTR_DQS
| From: | Truta446 | Date: | Tue, 03 Nov 2026 15:31:17 +0000 |
| Subject: | [php-src] PR #25173: Implement GH-13597: Add Pdo\Sqlite::ATTR_DQS | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40268@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25173
Author: Truta446
Fixes GH-13597
SQLite still accepts double-quoted string literals by default: if "abc" doesn't
resolve to a column, it quietly becomes the string 'abc'. SQLite calls this a misfeature,
and the sqlite3 shell has had it off since 3.41.0, but from PDO there was no way to turn it off. So
a query with a typo'd column name, or one written for another database, can pass in PHP tests
and then break elsewhere. That's the Doctrine case in the issue.
I added a boolean attribute that sets SQLITE_DBCONFIG_DQS_DML and SQLITE_DBCONFIG_DQS_DDL together.
It works as a constructor option or via setAttribute(), and getAttribute() returns true while either
one is still on. The default doesn't change. The constant only exists when building against
SQLite 3.29.0+, since that's where the options were added.
```php
$pdo = new Pdo\Sqlite('sqlite::memory:', options: [Pdo\Sqlite::ATTR_DQS => false]);
$pdo->query('SELECT "abc"'); // no such column: abc
```
I went with one switch instead of separate DML/DDL attributes because everyone asking for this wants
both off. Happy to split it or rename it if you prefer. I left the SQLite3 class out to keep this
small; it could get the same option in a follow-up.
@SakiTakamachi you offered to review this one on the issue, thanks.
Tested with the new gh13597.phpt plus ext/pdo_sqlite, ext/sqlite3 and ext/pdo on a master debug ASan
build, with and without opcache/JIT.