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

Command icon 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

mondrake created an issue. See original summary.

mondrake’s picture

Title: [PP-2] Enable dynamic queries to produce SQL with positional placeholders » [PP-1] Enable dynamic queries to produce SQL with positional placeholders
mondrake’s picture

Merged MR with #3259709: Create the database driver for MySQLi to allow progressing.

mondrake’s picture

Title: [PP-1] Enable dynamic queries to produce SQL with positional placeholders » [PP-2] Enable dynamic queries to produce SQL with positional placeholders
Related issues: +#3200743: Decouple identifier management from database Connection, introduce an IdentifierHandler class

While 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.