1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

19 commits

Author SHA1 Message Date
Pavel Gorbokon
96bae30538 Replace rudimentary named_scope with scope. [#6052 state:resolved]
* rename method names (actually in tests)
* rename instance variable @_named_scopes_cache to @_scopes_cache
* rename references in doc comments
* don't touch CHANGELOG :)
2010-12-15 14:02:30 -08:00
Aaron Patterson
76a15dd059 adding more tests surrounding where values hash 2010-11-29 16:41:02 -08:00
Aaron Patterson
9f2e885ce8 testing attributes applied by default_scope 2010-11-29 13:32:02 -08:00
Aaron Patterson
2738ec891b removing many unused variables 2010-11-16 17:06:50 -08:00
Jan
21beedf1ff default scope merge where clauses [#5488 state:resolved] 2010-10-20 09:00:36 -07:00
Aaron Patterson
e68f339aae default scope can accept any object that responds to #call 2010-10-19 15:07:44 -07:00
Tim Morgan
b1b26af9a2 Allow default_scope to accept a Proc. 2010-10-19 14:43:31 -07:00
Santiago Pastorino
e0b76d6151 reorder removed in favor of except(:order).order 2010-10-11 11:54:46 -02:00
Marcelo Giorgi
72543b2e63 Delegate ActiveRecord::Base.offset to scoped methods (analogous to limit) [#5688 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-24 20:24:54 -03:00
Aaron Patterson
3480551e67 removing nonsensical tests, limit now actually adds a limit 2010-09-15 14:18:16 -07:00
Nick Ragaz
16e078d908 failing test for reorder overriding default_scope
[5528]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-05 08:27:51 -03:00
Neeraj Singh
91fec0d24d order should always be concatenated.
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>
2010-09-05 08:13:42 -03:00
Pratik Naik
c07f0ae52e Change relation merging to always append select, group and order values 2010-08-31 19:17:18 +01:00
Xavier Noria
fb6b805620 code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them 2010-08-17 03:32:11 +02:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
José Valim
7131244313 Ensure default_scope can be overwriten by association conditions. 2010-07-21 15:06:23 +02:00
Subba Rao Pasupuleti
d77c3b669c eagerly loaded association records should respect default_scope [#2931 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 15:01:40 +02:00
Vitalii Khustochka
b75fca9e57 Added reorder delegation for ActiveRecord::Base(to be able to overwrite the default_scope ordering in the named scope [#5093 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-13 08:31:55 +02:00
José Valim
bd1666ad1d Add scoping and unscoped as the syntax to replace the old with_scope and 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
2010-06-29 17:18:55 +02:00