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 not expanded problem when passing an Array object as argument to the where method using composed_of column. #31724

Merged
merged 2 commits into from Jan 28, 2018

Conversation

@orekyuu
Copy link
Contributor

@orekyuu orekyuu commented Jan 17, 2018

Fixes #31723

david_balance = customers(:david).balance
Customer.where(balance: [david_balance]).to_sql

# Before: WHERE `customers`.`balance` = NULL
# After : WHERE `customers`.`balance` = 50
@rails-bot
Copy link

@rails-bot rails-bot commented Jan 17, 2018

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@orekyuu orekyuu force-pushed the orekyuu:fix-expand-composed-object-array branch 4 times, most recently Jan 17, 2018
@kamipo
Copy link
Member

@kamipo kamipo commented Jan 23, 2018

Can you more exercise tests for customer.address (mapping size: 2)?
Looks like this only work in case of mapping size: 1.

@orekyuu orekyuu force-pushed the orekyuu:fix-expand-composed-object-array branch Jan 24, 2018
@orekyuu
Copy link
Contributor Author

@orekyuu orekyuu commented Jan 24, 2018

@kamipo Added test with multiple mappings.

@kamipo
Copy link
Member

@kamipo kamipo commented Jan 24, 2018

Originally, if mapping size is 1, Customer.where(fullname: customer.fullname.to_s) treated as Customer.where(name: customer.fullname.to_s). If mapping size is more than 1, not allowed as invalid value.

In this PR, Customer.where(address: customer.address.country) will be treated as Customer.where(address_street: customer.address.country, address_city: customer.address.country, address_country: customer.address.country).
At least it should not be changed to fix #31723.

@kamipo kamipo added the activerecord label Jan 24, 2018
@orekyuu orekyuu force-pushed the orekyuu:fix-expand-composed-object-array branch Jan 26, 2018
…the where method using composed_of column.

Fixes #31723

```
david_balance = customers(:david).balance
Customer.where(balance: [david_balance]).to_sql

# Before: WHERE `customers`.`balance` = NULL
# After : WHERE `customers`.`balance` = 50
```
@orekyuu orekyuu force-pushed the orekyuu:fix-expand-composed-object-array branch to c9822ac Jan 26, 2018
@kamipo kamipo merged commit 41d34ae into rails:master Jan 28, 2018
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 added a commit that referenced this pull request Jan 28, 2018
Fix not expanded problem when passing an Array object as argument to the where method using composed_of column.
kamipo added a commit that referenced this pull request Jan 29, 2018
…appings

Follow up of #31724.

If `composed_of` objects have multiple mappings, array predicate handler
can not correctly handle the expanded condition.

We need to handle it like polymorphic association objects.
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

4 participants