SQLite should not use double quoted identifiers that are treated as string literal if column is missing (preventing an exception)

Created on 21 March 2023, almost 2 years ago

Problem/Motivation

In https://www.drupal.org/project/drupal/issues/3181013 🐛 Faulty permanent config cache has been set to the cache backend on failed sql server connection Fixed there is an issue with configuration storage and we need a test that can simulate a failure of storage. It does this well by creating tables with invalid schema so queries fail.

However, with SQLite storage used for a lot of testing, there is an issue in that it uses double quoted identifiers. Even though the schema is wrong and we are selecting from invalid columns - the query succeeds. This appears to be normal behaviour for double quoted identifiers:

https://www.sqlite.org/lang_keywords.html
> If a keyword in double quotes (ex: "key" or "glob") is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier.

Steps to reproduce

-

Proposed resolution

Change the identifiers to be either square brackets (MS Access compatibility) or grace accents (MySQL compatibility).
Although these are non-SQL conformant and for compatibility purposes - it's the only way to prevent a quoted identified from being treated as a string literal, and the only way I can currently think to allow us to write the tests needed for the above issue.

Remaining tasks

* Change identifierQuotes on the SQLite connection to square brackets
* Is a test required? I would anticipate as its configuration, it's not needed, and any regression here would begin failing the above issues tests if it was unblocked

User interface changes

None

API changes

Hopefully none, as this is in the driver layer, but arguably impacts all queries.

Data model changes

None

Release notes snippet

TBD

🐛 Bug report
Status

Active

Version

10.1

Component
SQLite driver 

Last updated 3 days ago

No maintainer
Created by

🇬🇧United Kingdom Driskell

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024