Skip to content

PHPLARA-73 Make id/_id column aliasing overridable via Grammar - #3539

Merged
GromNaN merged 1 commit into
mongodb:5.xfrom
GromNaN:phplara-73-overridable-id-aliasing
Jul 9, 2026
Merged

PHPLARA-73 Make id/_id column aliasing overridable via Grammar#3539
GromNaN merged 1 commit into
mongodb:5.xfrom
GromNaN:phplara-73-overridable-id-aliasing

Conversation

@GromNaN

@GromNaN GromNaN commented Jul 3, 2026

Copy link
Copy Markdown
Member

The top-level id to _id column rename in Builder::compileWheres() was hardcoded, which caused data corruption for users whose MongoDB documents have a business id field alongside _id (see #3392).

This delegates the aliasing to Grammar::prepareFieldsForQuery(), which is already the public overridable API (introduced in #3476). Users who need to disable the aliasing can now extend the Grammar class, consistent with Laravel's query builder architecture.

The alias_id connection config option (proposed in #3472) is not the right approach because compileWheres() runs before Grammar::prepareFieldsForQuery() at other call sites, so the Grammar hook would have received a payload where id had already been replaced by _id.

Ticket: https://jira.mongodb.org/browse/PHPLARA-73

Copilot AI review requested due to automatic review settings July 3, 2026 14:57
@GromNaN
GromNaN requested a review from a team as a code owner July 3, 2026 14:57
@GromNaN
GromNaN requested a review from paulinevos July 3, 2026 14:57
@github-actions github-actions Bot added the github label Jul 3, 2026
@GromNaN
GromNaN changed the base branch from 5.8 to 5.x July 3, 2026 14:57
Delegate the top-level `id` to `_id` column rename in
`Builder::compileWheres()` to `Grammar::prepareFieldsForQuery()` so users
can extend the Grammar to disable the aliasing when documents have a
business `id` field alongside `_id`.
@GromNaN
GromNaN force-pushed the phplara-73-overridable-id-aliasing branch from 93f5d08 to d013a90 Compare July 3, 2026 14:58
@mongodb mongodb deleted a comment from semgrep-code-mongodb Bot Jul 3, 2026

This comment was marked as outdated.

@GromNaN
GromNaN merged commit f100e48 into mongodb:5.x Jul 9, 2026
30 checks passed
@GromNaN
GromNaN deleted the phplara-73-overridable-id-aliasing branch July 9, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants