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

Quote colum_names when building select: #31403

Merged
merged 1 commit into from Dec 12, 2017

Conversation

Projects
None yet
4 participants
@Edouard-chin
Contributor

Edouard-chin commented Dec 11, 2017

Quote colum_names when building select:

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Dec 11, 2017

r? @kaspth

(@rails-bot has picked a reviewer for you, use r? to override)

rails-bot commented Dec 11, 2017

r? @kaspth

(@rails-bot has picked a reviewer for you, use r? to override)

Show outdated Hide outdated activerecord/test/cases/base_test.rb
Quote colum_names when building select:
- #30980 introcuded a change to not use `Arel.star` when model have ignored columns, a query used to look like `SELECT *. FROM developers` whereas now it would like `SELECT column1, column2 FROM developers`
  - If a column has the same name has a reserved database specific keyword (such as key, where ...) then the query would fail because the names aren't quoted
- Quoting almost always happen unless we use a `from` clause in the query https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1052
- This PR cast all columns name to symbols in order for the quoting logic to be picked up https://github.com/rails/rails/blob/9965b98dc0d58a86e10b4343bb6e15e01661a8c3/activerecord/lib/active_record/relation/query_methods.rb#L1054-L1055
- A reproduction script can be found here https://gist.github.com/Edouard-chin/f56d464a0adcb76962afc1a9134a1536
@Edouard-chin

This comment has been minimized.

Show comment
Hide comment
@Edouard-chin

Edouard-chin Dec 12, 2017

Contributor

Done thanks 🙇

Contributor

Edouard-chin commented Dec 12, 2017

Done thanks 🙇

@rafaelfranca rafaelfranca merged commit a681eaf into rails:master Dec 12, 2017

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

rafaelfranca added a commit that referenced this pull request Dec 12, 2017

Merge pull request #31403 from Edouard-chin/fix-quoted-columnname
Quote colum_names when building select:

@Edouard-chin Edouard-chin deleted the Edouard-chin:fix-quoted-columnname branch Dec 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment