-
Notifications
You must be signed in to change notification settings - Fork 22
Resolve historical join table via name/table_alias #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reasoning about the PR and the table in #388
Is this a good change?
Suggested commit message Problem
Changes
Why
Impact
Ref: #388 |
daa237c
to
a17edcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This refactor standardizes the historical join table resolution to use consistent Rails API methods across all supported versions. The PR simplifies code by removing branching logic for table name resolution and relies on the stable #name
and #table_alias
methods available in all supported Rails versions.
Key changes:
- Eliminates unnecessary branching on
#table_name
vs#name
methods - Standardizes on
join.left.name
for model resolution - Simplifies JoinNode implementation by removing duplicate attribute storage
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
lib/chrono_model/patches/relation.rb | Removes conditional table name resolution logic, standardizes on join_left.name |
lib/chrono_model/patches/join_node.rb | Simplifies JoinNode by removing attribute emulation and complex table name resolution |
a17edcb
to
238e6fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
238e6fc
to
13c89c5
Compare
All supported Rails versions consistently respond to `#name` and `#table_alias`, so branching on `#table_name` is unnecessary. This change standardizes on the stable API by resolving models via `join.left.name` and, in JoinNode, computing the virtual table name as `join_node.table_alias || join_node.name`. It also retains the early return in chrono_join_history when the join has already been wrapped and removes the emulation of `Arel::Table`-like readers from the SqlLiteral JoinNode. `respond_to?` guards in JoinNode have been removed because `Relation#chrono_join_history` only instantiates it for nodes that respond to `:name` (and `Arel::Table` provides `:table_alias` across all supported Rails versions), so this invariant is enforced at the call site. The generated SQL semantics are unchanged; the refactor simply aligns our code with the methods that are available across Rails supported rails versions and reduces maintenance Close #388
13c89c5
to
d00c3ad
Compare
All supported Rails versions consistently respond to
#name
and#table_alias
, so branching on#table_name
is unnecessary.This change standardizes on the stable API by resolving models via
join.left.name
and, in JoinNode, computing the virtual table name asjoin_node.table_alias || join_node.name
.It also retains the early return in chrono_join_history when the join
has already been wrapped and removes the emulation of
Arel::Table
-likereaders from the SqlLiteral JoinNode.
respond_to?
guards in JoinNode have been removed becauseRelation#chrono_join_history
only instantiates it for nodes thatrespond to
:name
(andArel::Table
provides:table_alias
acrossall supported Rails versions), so this invariant is enforced at the call
site.
The generated SQL semantics are unchanged; the refactor simply aligns
our code with the methods that are available across Rails supported
rails versions and reduces maintenance
Close #388