Skip to content

Use bitemporal_id as primary key for Rails 8+ excluding/without #252

Merged
kymmt90 merged 2 commits intomasterfrom
query-methods-excluding-pk
Apr 10, 2026
Merged

Use bitemporal_id as primary key for Rails 8+ excluding/without #252
kymmt90 merged 2 commits intomasterfrom
query-methods-excluding-pk

Conversation

@kymmt90
Copy link
Copy Markdown
Member

@kymmt90 kymmt90 commented Apr 9, 2026

This PR fixes the same problem as #251, but for AR::QueryMethods#excluding and #without.

excluding / without internally calls predicate_builder[primary_key, records]
to build a NOT IN clause. Without the primary_key override, this generates
WHERE id NOT IN (...) instead of WHERE bitemporal_id NOT IN (...),
causing incorrect record exclusion for bitemporal models with history.

This is the same class of issue fixed in PR #251 for AR::Batches.

kymmt90 and others added 2 commits April 9, 2026 19:16
`excluding` / `without` internally calls `predicate_builder[primary_key, records]`
to build a NOT IN clause. Without the primary_key override, this generates
`WHERE id NOT IN (...)` instead of `WHERE bitemporal_id NOT IN (...)`,
causing incorrect record exclusion for bitemporal models with history.

This is the same class of issue fixed in PR #251 for AR::Batches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kymmt90 kymmt90 requested a review from krororo April 10, 2026 02:20
@kymmt90 kymmt90 marked this pull request as ready for review April 10, 2026 02:20
@auto-assign auto-assign bot requested review from kumaie-shr and mkmn April 10, 2026 02:21
@kymmt90 kymmt90 removed the request for review from mkmn April 10, 2026 02:21
Copy link
Copy Markdown
Collaborator

@krororo krororo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@kymmt90 kymmt90 merged commit 8ab2bca into master Apr 10, 2026
20 checks passed
@kymmt90 kymmt90 deleted the query-methods-excluding-pk branch April 10, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants