aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation_scoping_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Construct an actual ActiveRecord::Relation object for the association scope, ↵Jon Leighton2011-01-071-1/+2
| | | | rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things.
* Make Relation#create_with always merge rather than overwrite, not just when ↵Jon Leighton2011-01-031-0/+10
| | | | merging two relations. If you wish to overwrite, you can do relation.create_with(nil), or for a specific attribute, relation.create_with(:attr => nil).
* Specify the STI type condition using SQL IN rather than a whole load of ORs. ↵Jon Leighton2010-12-311-0/+7
| | | | Required a fix to ActiveRecord::Relation#merge for properly merging create_with_value. This also fixes a situation where the type condition was appearing twice in the resultant SQL query.
* stop calling deprecated apisAaron Patterson2010-12-261-1/+1
|
* Replace rudimentary named_scope with scope. [#6052 state:resolved]Pavel Gorbokon2010-12-151-1/+1
| | | | | | | * rename method names (actually in tests) * rename instance variable @_named_scopes_cache to @_scopes_cache * rename references in doc comments * don't touch CHANGELOG :)
* adding more tests surrounding where values hashAaron Patterson2010-11-291-0/+11
|
* testing attributes applied by default_scopeAaron Patterson2010-11-291-0/+5
|
* removing many unused variablesAaron Patterson2010-11-161-2/+0
|
* default scope merge where clauses [#5488 state:resolved]Jan2010-10-201-0/+17
|
* default scope can accept any object that responds to #callAaron Patterson2010-10-191-0/+18
|
* Allow default_scope to accept a Proc.Tim Morgan2010-10-191-0/+11
|
* reorder removed in favor of except(:order).orderSantiago Pastorino2010-10-111-8/+2
|
* Delegate ActiveRecord::Base.offset to scoped methods (analogous to limit) ↵Marcelo Giorgi2010-09-241-0/+6
| | | | | | [#5688 state:resolved] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* removing nonsensical tests, limit now actually adds a limitAaron Patterson2010-09-151-1/+1
|
* failing test for reorder overriding default_scopeNick Ragaz2010-09-051-0/+6
| | | | | | [5528] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* order should always be concatenated.Neeraj Singh2010-09-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | order that is declared first has highest priority in all cases. Here are some examples. Car.order('name desc').find(:first, :order => 'id').name Car.named_scope_with_order.named_scope_with_another_order Car.order('id DESC').scoping do Car.find(:first, :order => 'id asc') end No special treatment to with_scope or scoping. Also note that if default_scope declares an order then the order declared in default_scope has the highest priority unless with_exclusive_scope is used. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Change relation merging to always append select, group and order valuesPratik Naik2010-08-311-6/+7
|
* code gardening: we have assert_(nil|blank|present), more concise, with ↵Xavier Noria2010-08-171-1/+1
| | | | better default failure messages - let's use them
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-2/+2
| | | | 's/[ \t]*$//' -i {} \;)
* Ensure default_scope can be overwriten by association conditions.José Valim2010-07-211-0/+5
|
* eagerly loaded association records should respect default_scope [#2931 ↵Subba Rao Pasupuleti2010-07-211-2/+16
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Added reorder delegation for ActiveRecord::Base(to be able to overwrite the ↵Vitalii Khustochka2010-07-131-0/+6
| | | | | | default_scope ordering in the named scope [#5093 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Add scoping and unscoped as the syntax to replace the old with_scope and ↵José Valim2010-06-291-0/+396
with_exclusive_scope. A few examples: * with_scope now should be scoping: Before: Comment.with_scope(:find => { :conditions => { :post_id => 1 } }) do Comment.first #=> SELECT * FROM comments WHERE post_id = 1 end After: Comment.where(:post_id => 1).scoping do Comment.first #=> SELECT * FROM comments WHERE post_id = 1 end * with_exclusive_scope now should be unscoped: class Post < ActiveRecord::Base default_scope :published => true end Post.all #=> SELECT * FROM posts WHERE published = true Before: Post.with_exclusive_scope do Post.all #=> SELECT * FROM posts end After: Post.unscoped do Post.all #=> SELECT * FROM posts end Notice you can also use unscoped without a block and it will return an anonymous scope with default_scope values: Post.unscoped.all #=> SELECT * FROM posts