aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/finder_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* fix visibility of the relation construction methodsAaron Patterson2013-07-091-5/+7
|
* pass arel to select_all rather than depend on method_missingAaron Patterson2013-07-091-1/+1
|
* Extract common query to a constant.Vipul A M2013-07-061-1/+3
| | | | Perf ref: https://gist.github.com/vipulnsward/8209749201dfdd678c97
* 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-281-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #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-141-3/+46
|\ \ | | | | | | | | | | | | 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
| | |
* | | we should apply the default scope before queryingAaron Patterson2013-06-121-1/+2
| | |
* | | Rather than raising ThrowResult when construct_limited_ids_conditions comes ↵Ben Woosley2013-05-101-13/+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.
* | Extract JoinDependency#join_relation to DRY the repeated application of the ↵Ben Woosley2013-05-101-4/+1
| | | | | | | | #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.
* | true/false => truthy falsySteve Klabnik2013-04-021-2/+2
| |
* | Throwing a RecordNotFound exception when a record is scanned using thewangjohn2013-04-011-11/+24
| | | | | | | | | | inverse_of option. I've also refactored the code for raising a RecordNotFound exception when searching for records with ids.
* | Fixed typos in activerecordPrathamesh Sonpatki2013-03-271-1/+1
| |
* | adds a missing LIMIT 1 in #take docsXavier Noria2013-02-231-1/+1
|/
* Do not instantiate intermediate AR objects when eager loading.Yves Senn2012-12-041-2/+4
| | | | Closes #3313
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-171-1/+1
|\ | | | | | | | | Conflicts: actionpack/lib/action_dispatch/routing/redirection.rb
| * 1.9 Syntax related changesAvnerCohen2012-11-101-1/+1
| |
* | Remove not used indifferent_access requires from Base and FinderMethodsCarlos Antonio da Silva2012-11-071-2/+0
| |
* | Use cached quoted_table_name instead of going through the connectionCarlos Antonio da Silva2012-11-071-1/+1
| |
* | Remove block given check from private find_with_idsCarlos Antonio da Silva2012-11-071-2/+0
|/ | | | | This is already handled by #find, it's a duplicate check, since find_with_ids is not called from anywhere else.
* Remove ActiveRecord::ModelJon Leighton2012-10-261-1/+1
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* AR::Relation#order: make new order prepend old oneBogdan Gusiev2012-07-311-1/+1
| | | | | | | User.order("name asc").order("created_at desc") # SELECT * FROM users ORDER BY created_at desc, name asc This also affects order defined in `default_scope` or any kind of associations.
* Deprecate Relation#all.Jon Leighton2012-07-271-14/+1
| | | | | | It has been moved to active_record_deprecated_finders. Use #to_a instead.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-06-301-5/+7
|\ | | | | | | | | Conflicts: activemodel/lib/active_model/errors.rb
| * update AR::FinderMethods#exists?(false) example [ci skip]Francesco Rodriguez2012-06-281-5/+7
| |
* | exists?(false) returns falseEgor Lynko2012-06-251-6/+6
|/ | | | `FinderMethods#exists?` finder method now returns *false* with the *false* argument
* Address ORA-00911 errors because of the heading underscore.Yasuo Honda2012-06-111-1/+1
|
* Fix that #exists? raises ThrowResult when called with an empty limitedBen Woosley2012-06-101-0/+2
| | | | | | | | | reflection. ActiveRecord::FinderMethods#construct_limited_ids_condition will raise ThrowResult if the limited reflection comes back empty. The other callers of #construct_limited_ids_condition handle this exception (more specifically, the callers of construct_relation_for*), but #exists? didn't until now.
* Add test to column alias in `exists?` SQL.Rafael Mendonça França2012-06-101-1/+1
| | | | | | | | This behavior was added in be4ecdcc87984e9421ff5d5c90d33f475e0fbc01. Closes #1139. Fixes #2553, #1141, #1623 and #2062.
* Minimal change to query generation of exists? that makes SQLServer and ↵iaddict2012-06-101-1/+1
| | | | | | | others happy that do not work without a column alias. Conflicts: activerecord/lib/active_record/relation/finder_methods.rb
* fix typo and remove 'examples' noise [ci skip]Francesco Rodriguez2012-05-281-18/+6
|
* Updates examples for FinderMethods [ci skip]Alvaro Pereyra2012-05-281-2/+14
|
* Merge branch 'master' of github.com:lifo/docrailsAlvaro Pereyra2012-05-281-0/+1
|\
* | Adds examples to FinderMethods#first [ci skip]Alvaro Pereyra2012-05-281-0/+1
| |
* | Remove blank trailing commentsHenrik Hodne2012-05-201-1/+0
|/ | | | | | | For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace with the first match, and voilà! Note that the regex matches a little bit too much, so you probably want to `git add -i .` and go through every single diff to check if it actually should be changed.
* Return false for exists? with new records - fixes #6199.Andrew White2012-05-101-2/+1
|