aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge pull request #11161 from dmitry/find_in_batches_works_without_loggerCarlos Antonio da Silva2013-06-281-2/+2
|\ | | | | | | | | ActiveRecord find_in_batches should work without logger When I set logger to nil both methods from Batches module find_in_batches or find_each should work anyway.
| * find_in_batches should work without loggerDmitry Polushkin2013-06-281-2/+2
| |
* | Remove order_values argument now that default_scope is simplifiedCarlos Antonio da Silva2013-06-281-5/+5
| | | | | | | | | | | | | | | | | | | | In 94924dc32baf78f13e289172534c2e71c9c8cade the internal default_scope implementation has changed making it simpler to follow, meaning that the old usage of with_default_scope has been removed. With that, order_values was the same argument for both calls to find_first_with_limit, so remove it and use the existent attribute for the sake of clarity/simplification.
* | Simplify/fix implementation of default scopesJon Leighton2013-06-285-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was necessary in order to support stuff like: class Post < ActiveRecord::Base default_scope where(published: true) scope :ordered, order("created_at") end If we didn't evaluate the default scope at the last possible moment before sending the SQL to the database, it would become impossible to do: Post.unscoped.ordered This is because the default scope would already be bound up in the "ordered" scope, and therefore wouldn't be removed by the "Post.unscoped" part. In 4.0, we have deprecated all "eager" forms of scopes. So now you must write: class Post < ActiveRecord::Base default_scope { where(published: true) } scope :ordered, -> { order("created_at") } end This prevents the default scope getting bound up inside the "ordered" scope, which means we can now have a simpler/better/more natural implementation of default scoping. A knock on effect is that some things that didn't work properly now do. For example it was previously impossible to use #except to remove a part of the default scope, since the default scope was evaluated after the call to #except.
* | Merge pull request #10992 from Empact/find-each-enumeratorCarlos Antonio da Silva2013-06-251-2/+13
|\ \ | | | | | | | | | When .find_each is called without a block, return an Enumerator.
| * | When .find_each is called without a block, return an Enumerator.Ben Woosley2013-06-191-2/+13
| |/ | | | | | | This lets us do things like call: .find_each.with_index
* / flatten merged join_values before building the joinsNeeraj Singh2013-06-221-1/+1
|/ | | | | | | | fixes #10669 While joining_values special treatment is given to string values. By flattening the array it ensures that string values are detected as strings and not arrays.
* Merge pull request #10898 from dmitry/find_first_refactor_duplicationRafael Mendonça França2013-06-141-11/+10
|\ | | | | Refactored ActiveRecord `first` method to get rid of duplication.
| * rename method `find_first_records` to `find_first_with_limit`Dmitry Polushkin2013-06-101-3/+3
| |
| * Refactored ActiveRecord `first` method to get rid of duplication.Dmitry Polushkin2013-06-091-11/+10
| |
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-06-142-22/+85
|\ \ | | | | | | | | | | | | Conflicts: guides/source/upgrading_ruby_on_rails.md
| * | copy edits [ci skip]Vijay Dev2013-06-141-19/+15
| | |
| * | doc: renaming table name to follow the file's standardsThiago Pinto2013-06-081-2/+2
| | |
| * | instructions for variations and alternatives for ActiveRecord#findThiago Pinto2013-06-081-1/+35
| | |
| * | explaining ActiveRecord#first in rails 3 and 4Thiago Pinto2013-06-081-0/+13
| | |
| * | lists the options for find_each and find_in_batchesThiago Pinto2013-06-071-17/+37
| | |
| * | using Model.all.find_each in rails 3 raises an error and should not be ↵Thiago Pinto2013-06-071-2/+2
| | | | | | | | | | | | recommended
* | | we should apply the default scope before queryingAaron Patterson2013-06-121-1/+2
| | |
* | | Remove fall back and column restrictions for `count`.Yves Senn2013-06-091-10/+6
| | |
* | | Merge pull request #10561 from Empact/nix-throwresultJon Leighton2013-06-072-15/+15
|\ \ \ | | | | | | | | Rather than raising ThrowResult when construct_limited_ids_conditions comes up empty, set the relation to NullRelation and rely on its results.
| * | | Rather than raising ThrowResult when construct_limited_ids_conditions comes ↵Ben Woosley2013-05-102-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | up empty, set the relation to NullRelation and rely on its results. This will help avoid errors like 2fcafee250ee2, because in most cases NullRelation will do the right thing. Minor bonus is avoiding the use of exceptions for flow control.
| * | | Fix that #pluck wasn't rescuing ThrowResult, meaning it would blow up when ↵Ben Woosley2013-05-101-0/+2
| | | | | | | | | | | | | | | | failing to construct_limited_ids_condition.
* | | | Remove #sum with a block was deprecated.kennyj2013-06-011-9/+1
| | | |
* | | | Merge pull request #10767 from jmondo/masterCarlos Antonio da Silva2013-05-291-1/+1
|\ \ \ \ | | | | | | | | | | Use grep instead of select with === in QueryMethods
| * | | | use grep over select for consistency and efficiencyJohn Gesimondo2013-05-281-1/+1
| | | | | | | | | | | | | | | | | | | | pass block directly to grep
* | | | | `implicit_readonly` is being removed in favor of calling `readonly` explicitlyYves Senn2013-05-271-5/+0
|/ / / /
* | | | avoid creating a set if no where values are removedAaron Patterson2013-05-211-0/+2
| | | |
* | | | remove bind values for where clauses that were removedAaron Patterson2013-05-211-9/+8
| | | |
* | | | push partitioning up so bind elimination can get the removed wheresAaron Patterson2013-05-211-5/+3
| | | |
* | | | push partion logic down and initialization logic upAaron Patterson2013-05-211-15/+11
| | | |
* | | | partition the where values so we can access the removed onesAaron Patterson2013-05-201-1/+6
| | | |
* | | | eliminate some conditionalsAaron Patterson2013-05-201-3/+3
| | | |
* | | | change method name to reflect what it actually does.Aaron Patterson2013-05-201-2/+2
| | | |
* | | | save the where values in variables so we don't need to look them up allAaron Patterson2013-05-201-4/+5
| | | | | | | | | | | | | | | | the time
* | | | pass where values to the helper function rather than rely on internal stateAaron Patterson2013-05-201-4/+4
| |/ / |/| |
* | | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-05-121-0/+3
|\ \ \ | |/ / |/| | | | | | | | Conflicts: activesupport/lib/active_support/callbacks.rb
| * | added to rdoc for unscope that default_scope winsNeeraj Singh2013-05-031-0/+3
| | |
* | | Extract JoinDependency#join_relation to DRY the repeated application of the ↵Ben Woosley2013-05-102-7/+2
| | | | | | | | | | | | #join_associations.
* | | In #apply_join_dependency, we can apply the #where in-place because relation ↵Ben Woosley2013-05-101-1/+1
| | | | | | | | | | | | | | | | | | is always a new object. Thanks to the #except we call at the top of the method.
* | | DRY-up join dependency creation by extracting construct_join_depdencyBen Woosley2013-05-101-7/+5
| | |
* | | Pull the excepts into apply_join_dependency, for the sake of DRY.Ben Woosley2013-05-101-3/+4
| | |
* | | Simplify conditions within apply_join_dependencyBen Woosley2013-05-101-9/+5
| | |
* | | Move the except(:select) inside the construct_limited_ids_condition method ↵Ben Woosley2013-05-101-2/+2
| | | | | | | | | | | | to pair it closely with its motivation.
* | | Reject blank order_values within #columns_for_distinct, as the orders aren't ↵Ben Woosley2013-05-101-2/+2
| | | | | | | | | | | | used at all on non-postgres adapters.
* | | Fix that #exists? can produce invalid SQL: "SELECT DISTINCT DISTINCT"Ben Woosley2013-05-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The combination of a :uniq => true association and the #distinct call in #construct_limited_ids_condition combine to create invalid SQL, because we're explicitly selecting DISTINCT, and also sending #distinct on to AREL, via the relation#distinct_value. Rather than build a select distinct clause in #construct_limited_ids_condition, I set #distinct! and pass just the columns into the select statement. This requires introducing a #columns_for_distinct method to return the select columns but not the statement itself.
* | | extracted piece of code into a methodNeeraj Singh2013-05-081-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to fix #10421 I need to enable merge to take an option so that relations could be merged without making the last where condition to win. That fix would forever reside in 4-0-stable branch and would not be merged to master since using scope without lambda has been deprecated. In this commit I have extracted code into a method and I think it makes code look better. Hence the request to merge it in both master and 4-0-stable. If there is any concern then this code can be merged only in 4-0-stable and that would be fine too.
* | | Handle aliased attributes in ActiveRecord::Relation.Godfrey Chan2013-05-012-8/+22
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database: With the model class Topic alias_attribute :heading, :title end The call Topic.where(heading: 'The First Topic') should yield the same result as Topic.where(title: 'The First Topic') This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`. This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`. Github #7839 *Godfrey Chan*
* | add missing :nodoc: marks to ActiveRecord::Delegation [ci skip]Francesco Rodriguez2013-04-291-3/+3
| |
* | When empty options passed to having clause having_values was [nil] but ↵Fyodor2013-04-231-1/+0
| | | | | | | | should be empty.
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-04-111-2/+1
|\ \ | | | | | | | | | | | | Conflicts: guides/source/action_mailer_basics.md