Open whmcs-ben opened 10 months ago
I am happy to submit this against the ORM repository if some investigation points to it being the culprit. As my discovery led me to the query cache and discussions on the net regarding reuse of PDOStatement
objects, I felt like starting at the driver level might be prudent.
Thank you for your time and work!
No duplicates 🥲.
Database
SQLite
What happened?
When query caching is enabled, if a constraint violation is encountered during an insert statement, a subsequent attempt to perform the same insert query will reuse the
PDOStatement
object stored in the cache, and its reuse will result in SQLite producing the following error:This situation occurs under two additional conditions:
Reproduction
I've attached a test script. The output will consist of
o
, record inserted, orx
constraint violated. Execution of this script under different conditions follows.Fresh database file, queryCache: false
Fresh database file, queryCache: true
Existing database file, queryCache: false
Existing database file, queryCache: true
Expectation
Regardless of whether the SQLite database file is created within the same process, a constraint violation in a prepared INSERT statement should not result in the same INSERT query later failing; whether it would encounter another constraint violation or not.
Version