aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-2/+2
| |\ \ \ | | |/ / | |/| | | | | | Make ActiveSupport frozen-string-literal friendly.
| | * | Make ActiveRecord frozen string literal friendly.Pat Allan2017-06-201-2/+2
| | | |
* | | | [Active Record] require => require_relativeAkira Matsuda2017-07-015-15/+15
|/ / /
* | | Fix the next version of Rails from 5.3 to 6.0Ryuta Kamizono2017-06-291-2/+2
| | |
* | | Deprecate delegating to `arel` in `Relation`Ryuta Kamizono2017-06-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Active Record doesn't rely delegating to `arel` in the internal since 425f2ca. The delegation is a lower priority than delegating to `klass`, so it is pretty unclear which method is delegated to `arel`. For example, `bind_values` method was removed at b06f64c (a series of changes https://github.com/rails/rails/compare/79f71d3...b06f64c). But a relation still could respond to the method because `arel` also have the same named method (#28976). Removing the delegation will achieve predictable behavior.
* | | Merge pull request #28932 from ↵Rafael França2017-06-281-10/+0
|\ \ \ | | | | | | | | | | | | | | | | kamipo/remove_method_missing_in_relation_delegation Remove `method_missing` in `Relation::Delegation`
| * | | Remove `method_missing` in `Relation::Delegation`Ryuta Kamizono2017-04-301-10/+0
| | | | | | | | | | | | | | | | The `method_missing` is never reached since 64c53d7c.
* | | | Merge pull request #29405 from kamipo/locked_should_not_build_arelRafael França2017-06-283-8/+4
|\ \ \ \ | | | | | | | | | | `Relation#locked?` should not build arel
| * | | | Remove delegating to arel in a relationRyuta Kamizono2017-06-293-8/+4
| | |/ / | |/| | | | | | | | | | | | | | The delegation was needed since passing `relation` with `relation.bound_attributes`. It should use `relation.arel` in that case.
* | | | Merge pull request #29556 from kamipo/extract_ordered_relationRafael França2017-06-271-12/+11
|\ \ \ \ | | | | | | | | | | Extract `ordered_relation` in `FinderMethods`
| * | | | Extract `ordered_relation` in `FinderMethods`Ryuta Kamizono2017-06-241-12/+11
| |/ / /
* / / / Fix extracting `references` via `order_values` to respect quotingRyuta Kamizono2017-06-261-1/+1
|/ / /
* | | Don't require 'unscope' to be the same for both sides of a 'or' relation.Dan Sherson2017-06-151-1/+1
| | |
* | | Prevent making bind param if casted value is nilRyuta Kamizono2017-05-312-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | If casted value is nil, generated SQL should be `IS NULL`. But currently it is generated as `= NULL`. To prevent this behavior, avoid making bind param if casted value is nil. Fixes #28945.
* | | Don't expose methods and attrs for internal usageRyuta Kamizono2017-05-302-4/+10
| | |
* | | Merge pull request #29098 from kamipo/fix_association_with_extension_issuesMatthew Draper2017-05-301-2/+0
|\ \ \ | | | | | | | | | | | | Fix association with extension issues
| * | | Fix association with extension issuesRyuta Kamizono2017-05-281-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following issues. * `association_scope` doesn't include `default_scope`. Should use `scope` instead. * We can't use `method_missing` for customizing existing method. * We can't use `relation_delegate_class` for sharing extensions. Should extend per association.
* | | | Deprecate passing arguments and block at the same time to `count` and `sum` ↵Ryuta Kamizono2017-05-291-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in `ActiveRecord::Calculations` `select`, `count`, and `sum` in `Relation` are also `Enumerable` method that can be passed block. `select` with block already doesn't take arguments since 4fc3366. This is follow up of that.
* | | | Merge pull request #29003 from kamipo/delegate_ast_and_locked_to_arel_explicitlyMatthew Draper2017-05-281-0/+2
|\ \ \ \ | |/ / / |/| | | Delegate `ast` and `locked` to `arel` explicitly
| * | | Delegate `ast` and `locked` to `arel` explicitlyRyuta Kamizono2017-05-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `ast` and `locked` are used in the internal but delegating to `arel` is depend on `method_missing`. If a model class is defined these methods, `select_all` will be broken. It should be delegated to `arel` explicitly.
* | | | Doc updates for ActiveRecord::BatchesT.J. Schuck2017-05-261-12/+12
| | | | | | | | | | | | [ci skip]
* | | | Avoid circular require due to autoloadMatthew Draper2017-05-261-9/+9
| | | |
* | | | Make `VALID_DIRECTIONS` to `Set`Ryuta Kamizono2017-05-201-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```ruby require "benchmark/ips" require "set" array = [:asc, :desc, :ASC, :DESC, "asc", "desc", "ASC", "DESC"] set = array.to_set item = "DESC" Benchmark.ips do |x| x.report "array" do array.include?(item) end x.report "set" do set.include?(item) end end ``` ``` % ruby array_vs_set.rb Warming up -------------------------------------- array 188.441k i/100ms set 229.531k i/100ms Calculating ------------------------------------- array 3.508M (± 9.0%) i/s - 17.525M in 5.043058s set 5.134M (± 7.6%) i/s - 25.707M in 5.038921s ```
* | | | Merge pull request #28919 from ↵Kasper Timm Hansen2017-05-121-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | meinac/fix_ambigious_exception_message_of_select_query_method Fix ambigious error message of select query method [ci skip]
| * | | | Fix ambigious error message of select query methodMehmet Emin INAC2017-05-081-1/+1
| | |/ / | |/| |
* | | | Don't eager loading if unneeded for `FinderMethods#exists?`Ryuta Kamizono2017-05-111-2/+4
| |/ / |/| | | | | | | | Fixes #29025.
* | | Don't pass `arel.engine` to `Arel::SelectManager.new`Ryuta Kamizono2017-05-051-2/+1
|/ / | | | | | | | | | | The argument of `Arel::SelectManager.new` is `table`, not `engine`. https://github.com/rails/arel/blob/v8.0.0/lib/arel/select_manager.rb#L10
* | Merge pull request #28828 from kamipo/fix_extending_modules_on_associationRafael França2017-04-251-0/+2
|\ \ | | | | | | Mixin `CollectionProxy::DelegateExtending` after `ClassSpecificRelation`
| * | Mixin `CollectionProxy::DelegateExtending` after `ClassSpecificRelation`Ryuta Kamizono2017-04-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `ClassSpecificRelation` has `method_missing` and the `method_missing` is called first. if an associated class has the missing method in a relation, never reach to the `method_missing` in the `CollectionProxy`. I extracted `DelegateExtending` and included it to the delegate class that including `ClassSpecificRelation` to fix the issue. Fixes https://github.com/rails/rails/pull/28246#issuecomment-296033784.
* | | `respond_to_missing?` should be privateRyuta Kamizono2017-04-221-5/+3
|/ / | | | | | | | | | | | | Follow up of 03d3f036. Some of `respond_to?` were replaced to `respond_to_missing?` in 03d3f036. But the visibility is still public. It should be private.
* | Merge pull request #28767 from kamipo/rename_to_association_query_valueAndrew White2017-04-153-8/+9
|\ \ | | | | | | Rename `association_query_handler.rb` to `association_query_value.rb`
| * | Rename `association_query_handler.rb` to `association_query_value.rb`Ryuta Kamizono2017-04-153-8/+9
| | | | | | | | | | | | | | | | | | Since `AssociationQueryHandler` and `PolymorphicArrayHandler` has removed in #28715, only exists `AssociationQueryValue` and `PolymorphicArrayValue` in these files.
* | | Early return in `PredicateBuilder::ArrayHandler`Ryuta Kamizono2017-04-151-4/+3
|/ / | | | | | | Partitioning to `values` and `nils` is unneeded before early return.
* | Merge pull request #28715 from ↵Andrew White2017-04-144-60/+32
|\ \ | | | | | | | | | | | | kamipo/convert_association_queries_to_poro_queries Convert association queries to PORO queries
| * | `AssociationQueryValue#queries` returns an array for more concise ↵Ryuta Kamizono2017-04-112-14/+7
| | | | | | | | | | | | association handling
| * | Convert `PolymorphicArrayValue` to PORO queriesRyuta Kamizono2017-04-093-28/+19
| | |
| * | Convert `AssociationQueryValue` to PORO queriesRyuta Kamizono2017-04-092-35/+23
| | |
* | | exclude ORDER BY clause for exists? (#28699)Boris Slobodin2017-04-101-1/+1
| | |
* | | Merge pull request #28713 from kamipo/expose_queries_for_association_queriesMatthew Draper2017-04-102-48/+44
|\| | | | | | | | Expose `queries` for `AssociationQueryValue` and `PolymorphicArrayValue`
| * | Expose `queries` for `AssociationQueryValue` and `PolymorphicArrayValue`Ryuta Kamizono2017-04-092-21/+25
| | |
| * | Avoid to handle polymorphic association for `AssociationQueryHandler`Ryuta Kamizono2017-03-282-29/+21
| | | | | | | | | | | | It should be handled by `PolymorphicArrayHandler` if polymorphic association.
* | | Extract `construct_relation_for_exists` in `FinderMethods`Ryuta Kamizono2017-04-091-12/+15
| | | | | | | | | | | | To ease to customize a relation for `exists?`.
* | | Revert "Merge pull request #28598 from wnadeau/patch-1"Rafael Mendonça França2017-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit a680a5814184e2f37c4686aa53d0ad3c7fb6b1ee, reversing changes made to 842f67dd242e738419f27e752ea7dcd0bbe87b6d. Reason: I can't resist to the joke, so better to keep it there https://github.com/rails/rails/pull/28598#issuecomment-290945339.
* | | FinderMethods#fourty_two docs cite proper sourceWinfred Nadeau2017-03-291-1/+1
|/ / | | | | | | | | | | | | silly method gets a silly doc fix, or I'm missing an even sillier joke and I'm about to get schooled. BUT I'm pretty sure this is some serious Beaudrillard simulacrum, though. I'm just doing my part to spread the gospel of Douglas Adams.
* | Merge pull request #28488 from kamipo/preprocess_association_query_handlingRafael França2017-03-271-13/+8
|\ \ | | | | | | Preprocess association query handling in predicate builder
| * | Always need to extract `value.bound_attributes` if `value.is_a?(Relation)`Ryuta Kamizono2017-03-251-3/+1
| | | | | | | | | | | | Because `RelationHandler` uses `value.arel`.
| * | Preprocess association query handling in predicate builderRyuta Kamizono2017-03-201-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently association query is handled as a postprocess. This has two problems. 1. When `value` is a `Hash`, we need to skip the postprocess using `next`. 2. `can_be_bound?` should return false if `table.associated_with?(column_name)` is true (pass to the postprocess). These are unneeded if preprocessing association query handling.
* | | Fix where_clause#except with specific where valueJohn Hawthorn2017-03-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes a regression introduced in 22ca710f20c3c656811df006cbf1f4dbc359f7a6 where Relation#unscope with a specific where value (vs unscoping the entire where clause) could result in the wrong binds being left on the query. This was caused by an index variable not being incremented properly.
* | | Use `load` rather than `collect` for force loadingRyuta Kamizono2017-03-191-1/+1
|/ / | | | | | | | | | | | | Since b644964b `ActiveRecord::Relation` includes `Enumerable` so delegating `collect`, `all?`, and `include?` are also unneeded. `collect` without block returns `Enumerable` without preloading by that. We should use `load` rather than `collect` for force loading.
* | Delegate `uniq` to `records`Ryuta Kamizono2017-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | This fixes CI failure due to 48f3be8c. `Enumerable#uniq` was introduced since Ruby 2.4. We should delegate `uniq` to `records` explicitly. And since b644964b `ActiveRecord::Relation` includes `Enumerable` so delegating `map` is unneeded.