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

10 commits

Author SHA1 Message Date
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