aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove unneeded requiresRafael Mendonça França2015-01-041-2/+0
| | | | These requires were added only to change deprecation message
* Rely on the injectable type caster for `arel_table`Sean Griffin2014-12-291-6/+1
| | | | | | | This API will require much less consuming code to change to accomodate the removal of automatic type casting from Arel. As long as the predicates are constructed using the `arel_table` off of an AR subclass, there will be no changes that need to happen.
* Eagerly cast array values passed to the predicate builderSean Griffin2014-12-261-1/+6
| | | | | | | | Part of a larger refactoring to remove type casting from Arel. /cc @mrgilman [Sean Griffin & Melanie Gilman]
* Re-use the predicate builder in the `ArrayHandler`Sean Griffin2014-12-261-3/+11
| | | | | | | | | | This reduces the number of places which will need to care about single value or range specific logic as we introduce type casting. The array handler is only responsible for producing `in` statements. /cc @mrgilman [Sean Griffin & Melanie Gilman]
* Add missing `:nodoc:`Sean Griffin2014-12-261-1/+1
| | | | | We're accidentally documenting `PredicateBuilder` and `ArrayHandler` since there's a constant which is missing `# :nodoc:`
* Remove deprecated behavior allowing nested arrays as query valuesMelanie Gilman2014-12-041-10/+0
|
* Use `#between`, rather than `#in` for passing Ranges to ArelSean Griffin2014-10-301-1/+1
| | | | Passing ranges to `#in` has been deprecated in Arel.
* let's warn with heredocsXavier Noria2014-10-281-3/+8
| | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* Fix query with nested array in Active RecordCristian Bica2014-09-061-4/+12
| | | | | | | | `User.where(id: [[1,2],3])` was equal to `User.where(id:[1, 2, 3])` in Rails 4.1.x but because of some refactoring in Arel this stopped working in 4.2.0. This fixes it in Rails. [Dan Olson & Cristian Bica]
* Allow empty arrays in where predicatesSean Griffin2014-05-261-0/+2
|
* Refactor the handling of arrays in where predicatesSean Griffin2014-05-261-11/+14
| | | | | | Simplifies the code slightly, isolates non-nil non-range values into a single array, which will make it easier to do things like apply type casting to them in the future.
* Add ability to specify how a class is converted to Arel predicatesgrif2013-07-281-0/+29
This adds the ability for rails apps or gems to have granular control over how a domain object is converted to sql. One simple use case would be to add support for Regexp. Another simple case would be something like the following: class DateRange < Struct.new(:start, :end) def include?(date) (start..end).cover?(date) end end class DateRangePredicate def call(attribute, range) attribute.in(range.start..range.end) end end ActiveRecord::PredicateBuilder.register_handler(DateRange, DateRangePredicate.new) More complex cases might include taking a currency object and converting it from EUR to USD before performing the query. By moving the existing handlers to this format, we were also able to nicely refactor a rather nasty method in PredicateBuilder.