Problem/Motivation

The values returned by ::execute() DML methods (INSERT, UPDATE, UPSERT, DELETE, MERGE) and from the TRUNCATE DDL method are inconsistent and fragile.

See discussions in #3567868: \Drupal\Core\Database\Query\Update::execute has wrong documentation for return type and #2547493: Add support for unique / primary key constraints composed of multiple fields for Upsert queries.

Proposed resolution

Change those classes execute methods not to return values, typehint them to void, where possible and solid provide additional methods that return details of the DML execution.

Remaining tasks

Discuss BC implications; then the rest of things.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3568486

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.

chi’s picture

I would remove return type from TRUNCATE method as well.

mondrake’s picture

Issue summary: View changes

#2 good point, added to the IS.

mondrake’s picture

Built MR 14429 on top of an MR from #3567868: \Drupal\Core\Database\Query\Update::execute has wrong documentation for return type. Let's see how much we fail.

ghost of drupal past’s picture

This is not necessary. We have solid affected rows support everywhere. Yes in upsert too see my comments there.

mondrake’s picture

Title: Change return of ::execute() DML methods (INSERT, UPDATE, UPSERT, DELETE, MERGE) to void » Change return of ::execute() DML/DDL methods (INSERT, UPDATE, UPSERT, DELETE, MERGE, TRUNCATE) to void

mondrake changed the visibility of the branch 3568486-change-return-of to hidden.

mondrake’s picture

Title: Change return of ::execute() DML/DDL methods (INSERT, UPDATE, UPSERT, DELETE, MERGE, TRUNCATE) to void » [meta] Change return of ::execute() DML/DDL methods (INSERT, UPDATE, UPSERT, DELETE, MERGE, TRUNCATE) to void

BC is complicated, because of the way consuming code is handling the returned value. I will try in child issues to introduce a new ::executeSafe() method typehinted void, and deprecate ::execute().