Skip to content
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

Support table aliases on associated relations #429

Open
wants to merge 2 commits into
base: release-3.6
Choose a base branch
from

Conversation

cllns
Copy link

@cllns cllns commented Jul 2, 2024

I discovered this bug the other week. If you call join with a relation object, table_alias doesn't work at all. It only works with the name a symbol.

Note this is a PR against release-3.6, not main.

Each commit fixes a different situations, so I recommend viewing each commit separately.

assoc = associations[other]
assoc = associations.key?(other) && associations[other]

if join_cond.eql?(EMPTY_HASH) && !block
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
if join_cond.eql?(EMPTY_HASH) && !block
if (join_cond.nil? || join_cond.empty?) && !block

I'd rather do this. It'd allow nil or {} or [] as join_cond, which are all valid IMO.

I'm not sure why this was .equal?, since that does object equality (so even passing in {} would be false since it's a different though identical object).

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.

1 participant