Vishnu Atrai
9a0e3d44d1
minor cleaning with new api method
2011-05-11 00:15:16 +05:30
Jon Leighton
5740d4ec0c
Deprecated support for passing hashes and relations to default_scope, in favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
2011-04-12 19:46:04 -07:00
Ernie Miller
fbd917f50a
Remove Relation#& alias for Relation#merge
2011-02-12 17:23:19 -08:00
Aaron Patterson
7e91ad3f89
stop calling deprecated apis
2010-12-26 19:56:18 -07:00
Aaron Patterson
cbca12f908
adding tests for #5234 and #5184 . Tests were from Akira Matsuda. Thanks Akira!
2010-10-30 13:20:54 -07:00
Marcelo Giorgi
cdfd013dd7
Set attributes properly for model built from association with conditions [ #5562 state:resolved]
...
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com >
2010-09-28 15:22:50 -03:00
Aaron Patterson
a11dd8ac87
specific number of spaces should not be enforced
2010-09-10 11:51:32 -07: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
Aaron Patterson
12b3eca420
do not rely on arel class structure
2010-08-06 11:31:05 -07:00
Subba Rao Pasupuleti
b0c7dee4f2
removing unused models from tests
...
[#5153 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-07-21 22:08:07 +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
Neeraj Singh
40e87ac669
with_exclusive_scope does not work properly if ARel is passed. It does work nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope.
...
[#3838 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-06-29 01:18:20 +02:00
Neeraj Singh and Santiago Pastorino
0ebb5bf659
Support for multiple selects added
...
[#4841 state:committed]
2010-06-25 15:57:04 -03:00
Neeraj Singh
39a246f545
Final iteration of use better testing methods
...
[#4652 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-05-19 21:31:51 +02:00
Pratik Naik
5ddc904941
Remove Model.clear_default_scope
2010-05-18 12:22:23 +01:00
David Chelimsky + Brian Tatnall
35a114a894
Modified default_scope to merge with any pre-existing default_scope
...
and added AR::Base::clear_default_scope
- clear_default_scope provides users who rely on the old behaviour
of each call to default_scope overwriting any previous default
scopes an opportunity to maintain that behaviour.
[#4583 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-05-15 08:38:28 +02:00
Aaron Patterson
1def14309f
cleaning up a bunch of parse time warnings in AR [ #4186 state:resolved]
...
Signed-off-by: wycats <wycats@gmail.com >
2010-03-15 18:22:31 -07:00
Henry Hsu
bf9a0ae12b
Fix a bug where default_scope was overriding attributes given on model initialization [ #3218 status:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-02-26 11:09:43 +01:00
Pratik Naik
8ff2fb6f3a
Make default_scope work with Relations
2010-01-23 13:41:09 +05:30
Pratik Naik
9acf0af544
Remove Relation#where_clause
2010-01-19 23:11:54 +05:30
Pratik Naik
8bb5274648
Get rid of Relation#order_clauses
2010-01-18 18:56:55 +05:30
Pratik Naik
54a043895f
Make merging of order values consistent
2010-01-17 14:19:41 +05:30
Pratik Naik
bed9179aa1
Make scopes use relations under the hood
2010-01-16 00:02:46 +05:30
Jeremy Kemper
949c8c0d0e
Don't publicize with_scope for tests since it may shadow public misuse
2009-12-28 14:07:23 -08:00
Emilio Tagua
3747f896a1
Moved relation's test to relation_test.
2009-10-05 14:39:20 -03:00
Emilio Tagua
9520143159
Merge commit 'rails/master'
...
Conflicts:
activerecord/test/cases/adapter_test.rb
activerecord/test/cases/method_scoping_test.rb
2009-08-08 19:14:35 -03:00
Raimonds Simanovskis
ee654e54c4
Oracle generates different ORDER BY fragment
2009-08-06 23:40:59 +03:00
Emilio Tagua
0e0866e056
Introduced ActiveRecord::Relation, a layer between an ARel relation and an AR relation
2009-07-21 20:21:03 -03:00
Emilio Tagua
1cc4459939
Merge commit 'rails/master'
...
Conflicts:
activerecord/lib/active_record.rb
Updated:
Arel submodule
2009-05-18 20:01:06 -03:00
Pratik Naik
c5e109bbe7
Make sure default_scope#create checks for options[:conditions] [ #2181 state:resolved] [James Le Cuirot]
2009-05-18 21:27:42 +02:00
Emilio Tagua
5e790d368c
Merge commit 'rails/master'
2009-05-02 03:21:40 -03:00
Alexander Podgorbunsky
db0bfe4ede
Default scope :order should be overridden by named scopes.
...
[#2346 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-05-01 14:44:24 -07:00
Emilio Tagua
090539604b
construct_finder_sql now use Arel
2009-04-24 21:48:45 -03:00
Emilio Tagua
a841cd2503
Fix models load order to be able to run unit tests.
...
[#2550 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-04-23 16:02:11 -07:00
Jeremy Kemper
19ad375e7a
Don't duplicate :order from scope and options, it makes mysql do extra work
2009-03-10 23:11:05 -07:00
Manfred Stienstra
c3aa2bcdcf
Ensure nested with_scope merges conditions inside out [ #2193 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2009-03-10 11:49:58 +00:00
rick
1cfc39e7e7
update the default scope test to take the model's default scope into account
2009-02-25 09:27:44 -08:00
Filip H.F. "FiXato" Slagter
a0d8202bb9
Ensure whitespaces are stripped when merging string joins. [ #1297 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2009-01-28 19:50:55 +00:00
Daniel Luz
f7bd0beb67
Ensure Model#last doesn't affects order for another finders inside the same scope [ #1499 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-12-21 23:24:06 +00:00
Tom Stuart
32cb2345a5
Fix default_scope to work in combination with named scopes
...
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com >
2008-11-17 22:00:14 +01:00
Pratik Naik
2530d0eea8
Added default_scope to Base [ #1381 state:committed] (Paweł Kondzior)
2008-11-16 23:36:41 +05:30
David Heinemeier Hansson
ca23287b44
Revert "Added default_scope to Base [ #1381 state:committed] (Paweł Kondzior)" -- won't gel with threads.
...
This reverts commit ff594b2bc9 .
2008-11-16 16:35:52 +01:00
David Heinemeier Hansson
ff594b2bc9
Added default_scope to Base [ #1381 state:committed] (Paweł Kondzior)
2008-11-16 16:01:18 +01:00
Pivotal Labs
487758b3b8
Allowed passing arrays-of-strings to :join everywhere. Merge duplicate join strings to avoid table aliasing problems.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1077 state:committed]
2008-09-24 13:26:06 +02:00
Andrew White
db22c89543
Merge scoped :joins together instead of overwriting them. May expose scoping bugs in your code!
...
[#501 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-28 12:07:15 -07:00
Tarmo Tänav
82343859d5
Added missing fixtures for tests which fail to run independently if run after schema reset
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-08-04 11:50:15 +02:00
Mark Catley
0fd3e4cd2b
Fix column collision with named_scope and :joins. [ #46 state:resolved]
2008-06-22 19:21:15 -07:00
Andrew White
235d635708
Ensure :select passed in options overrides the one from the scope. [ #239 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-05-29 14:10:24 +01:00
Jeremy Kemper
0ff031992f
Fix merging blank conditions. Closes #10764 [mcmire, cavalle]
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9082 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-23 05:00:25 +00:00
Jeremy Kemper
39814fcce0
Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/rails
...
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-21 17:20:51 +00:00