PostgreSQL orderBy method adds fields it doesn't need to, leading to fatal errors when the result is used as an insert subquery

Created on 5 August 2013, almost 11 years ago
Updated 29 March 2023, over 1 year ago

Problem/Motivation

See #1759144: taxonomy_update_7005 on pgsql returns error "column "td" of relation "taxonomy_update_7005" does not exist" β†’ for an initial description of the bug and an actual example that triggers it in the Drupal 7 codebase.

The code in Drupal\Core\Database\Driver\pgsql::orderBy() looks identical in Drupal 8, so I assume the bug exists there too.

Proposed resolution

Determine if there is no need for the orderBy method, and add tests for the bug in the problem/motivation section above.

Remaining tasks

User interface changes

None.

API changes

This is not an API change, but a behavior change. The pgsql driver no longer makes an assumption about what it does or does not need to do during an orderBy. Contrib developers may need to make changes if they rely on select queries with ambiguous fields when using distinct and orderBy. These queries do not appear in Drupal core so the driver should not need to make these adjustments automatically.

Data model changes

None.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
PostgreSQL driverΒ  β†’

Last updated 6 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States David_Rothstein

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • PostgreSQL

    Particularly affects sites running on the PostgreSQL database.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024