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

Fix referencing wrong aliases while joining tables of has many through association #19452

Conversation

@pinglamb
Copy link
Contributor

commented Mar 22, 2015

Fix for Issue #19276.

While joining table of has_many :through association, ActiveRecord will use the actual table name instead of through-join alias. It results with a wrong SQL and exception is raised. This only happens when calculation methods like #count is called.

This bug is affecting Rails 4.1.x and 4.2.x as well.

Fix referencing wrong aliases while joining tables of has many through
association

While joining table of has_many :through association, ActiveRecord will
use the actual table name instead of through-join alias. It results with
a wrong SQL and exception is raised. This only happens when calculation
methods like #count is called.

This issue is affecting Rails 4.1.x and 4.2.x as well.
carlosantoniodasilva added a commit to carlosantoniodasilva/rails that referenced this pull request Mar 24, 2015
Merge pull request rails#19452 from pinglamb/fix-referencing-wrong-al…
…ias-when-joining-tables-of-has-many-through-association

Fix referencing wrong aliases while joining tables of has many through association

@carlosantoniodasilva carlosantoniodasilva merged commit ba057a5 into rails:master Mar 24, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
carlosantoniodasilva added a commit that referenced this pull request Mar 24, 2015
Merge pull request #19452 from pinglamb/fix-referencing-wrong-alias-w…
…hen-joining-tables-of-has-many-through-association

Fix referencing wrong aliases while joining tables of has many through association
carlosantoniodasilva added a commit that referenced this pull request Mar 24, 2015
Merge pull request #19452 from pinglamb/fix-referencing-wrong-alias-w…
…hen-joining-tables-of-has-many-through-association

Fix referencing wrong aliases while joining tables of has many through association
@carlosantoniodasilva

This comment has been minimized.

Copy link
Member

commented Mar 24, 2015

Backports:

Thanks.

vanvenegas pushed a commit to fluxfederation/rails that referenced this pull request Aug 3, 2015
Merge pull request rails#19452 from pinglamb/fix-referencing-wrong-al…
…ias-when-joining-tables-of-has-many-through-association

Fix referencing wrong aliases while joining tables of has many through association
kamipo added a commit to kamipo/rails that referenced this pull request Jun 12, 2016
Fix `calculate` with a string value in `from` and eager loading
`construct_relation_for_association_calculations` pass a string value to
`construct_join_dependency` when setting a string value in `from`.
It should not pass a string value, but always `joins_values`.

Related rails#14834, rails#19452.

Fixes rails#24193.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.