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

Allow scopes that define string SQL joins #1225

Merged

Conversation

mhssmnn
Copy link
Contributor

@mhssmnn mhssmnn commented May 12, 2021

Allows scopes to add a string join for more complex joins. These changes fix an issue when using a string join in combination with a negated condition on a relation:

NoMethodError:
    undefined method `children' for nil:NilClass
    # ./lib/ransack/adapters/active_record/context.rb:143:in `block in remove_association'

because this line was acting on a string:

@object.joins_values.delete_if { |jd|
    jd.instance_variable_get(:@join_root).children.map(&:object_id) == [association.object_id]
}

@scarroll32
Copy link
Member

This is a nice feature @mhssmnn, thank you 🎉
Would it be possible to add a note to the README ?

@scarroll32 scarroll32 mentioned this pull request Mar 10, 2022
13 tasks
@scarroll32 scarroll32 merged commit be8c464 into activerecord-hackery:master Mar 27, 2022
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