Problem/Motivation
Drupal's dynamic queries produce SQL with named placeholders. In #3259709: Create the database driver for MySQLi, since mysqli is NOT supporting named placeholders, we are introducing an helper class that converts an SQL with named placeholders to one with positional ones.
This is inefficient, since it has to deconstruct a ready SQL statement and rebuild it.
Proposed resolution
Introduce logic that enables dynamic queries to produce SQL with either named or positional placeholders, and prevent mysqli driver to run through the converter if a statement is already built with positional parameters.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3399150
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mondrakeComment #4
mondrakeMerged MR with #3259709: Create the database driver for MySQLi to allow progressing.
Comment #5
mondrakeWhile it's relatively straightforward to do this for plain INSERTs, this get complicated for all other operations where conditions get into the equation. The problem is that named placeholders are allowed in the expressions' string: while we could easily parse the strings to replace them with positional ones, that would defy the purpose of this issue that is to natively build SQL with positional placeholders, without need of reprocessing.
I start thinking we need something along the lines of #3200743: Decouple identifier management from database Connection, introduce an IdentifierHandler class, but for placeholders. So to have placeholders as value objects and not strings and therefore being able to build SQL taking that into account.