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

`where` by `array|range` attribute with array or range value #26074

Merged
merged 1 commit into from Aug 16, 2016

Conversation

Projects
None yet
6 participants
@kamipo
Member

kamipo commented Aug 6, 2016

Currently predicate builder cannot build a predicate for array|range
attribute. This commit fixes the issue.

Related #25671.

@rails-bot

This comment has been minimized.

rails-bot commented Aug 6, 2016

r? @arthurnn

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

@kamipo kamipo force-pushed the kamipo:where_by_attribute_with_array_or_range branch 2 times, most recently Aug 6, 2016

@esparta

View changes

activerecord/lib/active_record/relation/predicate_builder.rb Outdated
@@ -98,14 +98,13 @@ def create_binds_for_hash(attributes)
binds = []
attributes.each do |column_name, value|
case value
when Hash
if value.is_a?(Relation)

This comment has been minimized.

@esparta

esparta Aug 7, 2016

Contributor

What about keep the case statement?

case
when value.is_a?(Relation)
  ...
when value.is_a?(Hash)
 ...
when ->(v) { v.is_a?(Range) and !table.type(column_name).respond_to?(:subtype) }
 ...
end
`where` by `array|range` attribute with array or range value
Currently predicate builder cannot build a predicate for `array|range`
attribute. This commit fixes the issue.

Related #25671.

@kamipo kamipo force-pushed the kamipo:where_by_attribute_with_array_or_range branch to f79d55a Aug 11, 2016

case value
when Hash
case
when value.is_a?(Hash)

This comment has been minimized.

@kamipo

kamipo Aug 12, 2016

Member

@esparta Thank you for your suggestion. I changed to keep the case statement. Thanks!

@rafaelfranca rafaelfranca merged commit d60f349 into rails:master Aug 16, 2016

2 checks passed

codeclimate Code Climate has skipped analysis of this commit.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kamipo kamipo deleted the kamipo:where_by_attribute_with_array_or_range branch Aug 16, 2016

kamipo added a commit to kamipo/rails that referenced this pull request May 25, 2018

Make force equality checking more strictly not to allow serialized at…
…tribute

Since rails#26074, introduced force equality checking to build a predicate
consistently for both `find` and `create` (fixes rails#27313).

But the assumption that only array/range attribute have subtype was
wrong. We need to make force equality checking more strictly not to
allow serialized attribute.

Fixes rails#32761.

kamipo added a commit that referenced this pull request May 25, 2018

Make force equality checking more strictly not to allow serialized at…
…tribute

Since #26074, introduced force equality checking to build a predicate
consistently for both `find` and `create` (fixes #27313).

But the assumption that only array/range attribute have subtype was
wrong. We need to make force equality checking more strictly not to
allow serialized attribute.

Fixes #32761.

kamipo added a commit that referenced this pull request May 25, 2018

Make force equality checking more strictly not to allow serialized at…
…tribute

Since #26074, introduced force equality checking to build a predicate
consistently for both `find` and `create` (fixes #27313).

But the assumption that only array/range attribute have subtype was
wrong. We need to make force equality checking more strictly not to
allow serialized attribute.

Fixes #32761.

kamipo added a commit that referenced this pull request May 25, 2018

Make force equality checking more strictly not to allow serialized at…
…tribute

Since #26074, introduced force equality checking to build a predicate
consistently for both `find` and `create` (fixes #27313).

But the assumption that only array/range attribute have subtype was
wrong. We need to make force equality checking more strictly not to
allow serialized attribute.

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