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 where with a custom table #29796

Merged
merged 1 commit into from Jul 17, 2017
Merged

Conversation

@kamipo
Copy link
Member

@kamipo kamipo commented Jul 14, 2017

Without this fix, SELECT clause doesn't use a custom table alias name:

% ARCONN=sqlite3 be ruby -w -Itest test/cases/relations_test.rb -n test_using_a_custom_table_affects_the_wheres
Using sqlite3
Run options: -n test_using_a_custom_table_affects_the_wheres --seed 31818

E

Error:
RelationTest#test_using_a_custom_table_affects_the_wheres:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: posts: SELECT  "posts".* FROM "posts" "omg_posts" WHERE "omg_posts"."title" = ? LIMIT ?
@kamipo kamipo force-pushed the kamipo:fix_where_with_custom_table branch 7 times, most recently Jul 15, 2017
activerecord/test/cases/relations_test.rb Outdated
node = relation.arel.constraints.first.grep(Arel::Attributes::Attribute).first
assert_equal table_alias, node.relation
post = posts(:welcome)
assert_equal post, OmgPost.where(title: post.title).take

This comment has been minimized.

@sgrif

sgrif Jul 17, 2017
Contributor

This seems like it's just a cosmetic change. It also makes it much less clear from the code what's being tested.

Without this fix, SELECT clause doesn't use a custom table alias name:

```
% ARCONN=sqlite3 be ruby -w -Itest test/cases/relations_test.rb -n test_using_a_custom_table_affects_the_wheres
Using sqlite3
Run options: -n test_using_a_custom_table_affects_the_wheres --seed 31818

E

Error:
RelationTest#test_using_a_custom_table_affects_the_wheres:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: posts: SELECT  "posts".* FROM "posts" "omg_posts" WHERE "omg_posts"."title" = ? LIMIT ?
```
@kamipo kamipo force-pushed the kamipo:fix_where_with_custom_table branch to 26ba655 Jul 17, 2017
@sgrif sgrif merged commit cdf4046 into rails:master Jul 17, 2017
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
codeclimate All good!
Details
@kamipo
Copy link
Member Author

@kamipo kamipo commented Jul 17, 2017

Thanks for your review. I updated the PR.

@sgrif
Copy link
Contributor

@sgrif sgrif commented Jul 17, 2017

Github notifies me when you update. :)

@kamipo kamipo deleted the kamipo:fix_where_with_custom_table branch Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants