Aaron Patterson
6ceffb8178
adding bind_values to relations
2010-10-26 13:44:07 -07:00
Aaron Patterson
ee71a3fbfc
removing call to deprecated API, this test is outside AR responsibilities
2010-10-22 13:33:59 -07:00
Santiago Pastorino
e0b76d6151
reorder removed in favor of except(:order).order
2010-10-11 11:54:46 -02:00
Aaron Patterson
133742d185
@klass also uses DynamicFinderMatch, so no need for it on the relation
2010-09-27 16:51:12 -07:00
Neeraj Singh
9401fa0b9c
expanding the test to include both type of order declaration
...
while declaring default_scope
Also added test for unscoped using block style with four different
combinations
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-18 20:49:19 +02:00
Aaron Patterson
3480551e67
removing nonsensical tests, limit now actually adds a limit
2010-09-15 14:18:16 -07:00
kane
1c283765b6
added a test for relation which checks intersection between a relation and an array works in both directions
...
Signed-off-by: Mikel Lindsaar <raasdnil@gmail.com>
2010-09-10 21:13:57 +10:00
Emilio Tagua
e3246ef5b5
Add tests for Relation#only.
2010-09-09 15:27:10 -03:00
Aaron Patterson
604281221c
select should raise error when no block or no parameter is passed
2010-09-07 10:48:14 -07: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
Emilio Tagua
2ce57fd0d9
Fix test: this should return 0 not 7, since Arel was ignoring select clause and now it's fixed.
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 15:09:38 +02: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
Neeraj Singh
6ed1ba472e
Ensure we can nest include calls [ #5285 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:10:58 -03:00
Aaron Patterson
e1596be323
test to ensure that respond_to? delegates to arel
2010-08-06 15:23:25 -07:00
Aaron Patterson
d082a9a2b8
sorry AR, my privates are none of your business
2010-08-06 14:53:01 -07:00
Aaron Patterson
834e304b22
reverting where() functionality, adding a test
2010-07-30 14:12:01 -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
Santiago Pastorino
47134a04bb
blocks removed from all the ActiveRelation query_methods, extend method added instead
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-26 01:35:23 +02:00
Santiago Pastorino
65aa6a7db1
reorder method added to ActiveRelation
...
[#4972 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-26 00:59:12 +02:00
Santiago Pastorino
a2513aea07
Test for concatenated orders added
...
[#4972 ]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-26 00:59:11 +02:00
Neeraj Singh and Santiago Pastorino
0ebb5bf659
Support for multiple selects added
...
[#4841 state:committed]
2010-06-25 15:57:04 -03:00
Emilio Tagua
5441e082f9
Add tests for relation count. Fix other tests that were conceptually wrong.
...
[#4882 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-24 11:41:55 +02:00
Neeraj Singh
0bf3baa6b3
adding fix for to_xml for ActiveRecord relation object
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-23 18:00:32 +02:00
Neeraj Singh
eb04408a20
ActiveRecord's relation object should respond to to_json and to_yaml
...
[#4547 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-23 18:00:25 +02:00
Neeraj Singh
7033be5f72
test for #4917
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-22 18:04:38 +02:00
Emilio Tagua
7df105b1e6
Fix order method to accept relation attributes.
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-22 16:44:10 +02:00
Santiago Pastorino
94ed39d146
This test shouldn't rely on the order of the data returned by select
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-07 20:06:31 -04:00
Pratik Naik
4b91daff13
Special treatement for Relation#select { with block }
2010-06-02 14:42:25 +01: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
b77dd218ce
Add Relation extensions
2010-04-02 17:38:02 +01:00
Pratik Naik
4afd9702fe
Relation should respond to class methods
2010-01-22 20:14:37 +05:30
Pratik Naik
2a2bc8e84a
Handle invalid query IN() generated when a blank array is supplied in hash conditions
2010-01-18 18:56:55 +05:30
Pratik Naik
e1d507c7fb
Dont check for class equaity when merging relations
2010-01-18 04:28:21 +05:30
Pratik Naik
8d87c80c19
Make Relation#reload force load the records immediately
2010-01-17 04:25:59 +05:30
Pratik Naik
a68165833a
Add Relation#create_with to explictily specify create scope
2010-01-04 03:50:16 +05:30
Pratik Naik
00f3f6dc31
Relation#merge and Relation#except should respect locks
2010-01-03 21:25:19 +05:30
Pratik Naik
af5e1b4cc6
Add Relation#except
2010-01-03 19:43:29 +05:30
Pratik Naik
3eca0ab838
Give preference to the second relation's order when merging
2010-01-03 18:52:30 +05:30
Pratik Naik
6f5f23aaa7
Add Relation#includes to be an equivalent of current finder option :include
2010-01-03 03:24:28 +05:30
Pratik Naik
ac1df91e5e
Implement Relation#create and Relation#create!
2010-01-03 00:16:14 +05:30
Pratik Naik
65200d2933
Implement Relation#new
2010-01-03 00:08:59 +05:30
Pratik Naik
8734f9a271
Relation#many? shoud load the records if there's a LIMIT
2009-12-30 12:14:00 +05:30
Pratik Naik
bdf59a5618
Add Relation#any? and Relation#many?
2009-12-30 12:11:22 +05:30
Pratik Naik
a56518aee2
Fix the count test for postgres
2009-12-30 10:41:47 +05:30
Emilio Tagua
00cd3789f6
Relation#count should look for projections in chained relations and perform the count on the given column
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-12-30 01:12:38 +05:30
Pratik Naik
981f696398
Relation#respond_to? should take second argument for responding to private methods
2009-12-29 12:31:08 +05:30
Pratik Naik
bc933d0fa1
Make sure Relation responds to dynamic finder methods
2009-12-29 12:27:40 +05:30
Pratik Naik
f290e685f0
Add Relation#size and Relation#empty?
2009-12-29 12:15:28 +05:30