Follow up of #2547493: Add support for unique / primary key constraints composed of multiple fields for Upsert queries.

Problem/Motivation

Use the upsert with composite key capability in core where appropriate.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3586760

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

Status: Active » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

merge with main

mondrake’s picture

Uhm upsert with multiple values seems not to really work. Reverted to 480019bf .

mondrake’s picture

KeyValueStore\DatabaseStorage::setMultiple() may be passed an empty array in which case we need to bail out immediately.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Needs review

rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

rebased

mondrake’s picture

Status: Reviewed & tested by the community » Needs review

Ops, did not notice it was NR and not RTBC. Putting back.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, let's make it RTBC after all :)

mondrake’s picture

Status: Reviewed & tested by the community » Needs work

Tried to run on all dbs, mysqli seems to have a consistent fail in kernel tests. Checking.

mondrake’s picture

mysqli failure is due to mysqli and mysql having a different returned value from Upsert::execute() related to internals of affected rows calculations.

See #3569213: Deprecate UPSERT ::execute() method returning a value and some discussions on #2547493: Add support for unique / primary key constraints composed of multiple fields for Upsert queries.

I stand by my opinion expressed there that we should not rely on those returned values in any case. While that would be preferable, here I am just changing the test to reread the data after the rewrite and checking that it still as prior (which is an even more accurate test imho anyway).

mondrake’s picture

Status: Needs work » Needs review

Thanks @catch for review. Mysqli failure was not trivial, so I need to put back to NR for one more round.

mondrake’s picture

Green on all dbs now.

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

LGTM!

alexpott’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed and pushed d7f1e63a569 to main. Thanks!

We should backport this to 11.x

  • alexpott committed d7f1e63a on main
    task: #3586760 Use composite key Upsert queries in core
    
    By: mondrake
    By...

mondrake changed the visibility of the branch 3586760-use-composite-key to hidden.

mondrake’s picture

Status: Patch (to be ported) » Needs review
mondrake’s picture

AFAICS the functional test failure due to a deprecation occurs in HEAD too

catch’s picture

Status: Needs review » Reviewed & tested by the community

Backport looks good!

alexpott’s picture

Version: 11.x-dev » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 8ba2f05e904 to 11.x and c8c3972c9f1 to 11.4.x. Thanks!

Backported to 11.4.x as a nice small performance improvement for using existing API.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed c8c3972c on 11.4.x
    task: #3586760 Use composite key Upsert queries in core
    
    By: mondrake
    By...

  • alexpott committed 8ba2f05e on 11.x
    task: #3586760 Use composite key Upsert queries in core
    
    By: mondrake
    By...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.