Commit Graph

69 Commits

Author SHA1 Message Date
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
Pratik Naik
54b80c7361 Add Relation#delete_all 2009-12-29 11:46:07 +05:30
Pratik Naik
8f5d9eb0e2 Add Relation#count 2009-12-28 18:38:28 +05:30
Pratik Naik
b95cc72429 Raise ArgumentError when trying to merge relations of different classes 2009-12-28 14:24:52 +05:30
Pratik Naik
630dc50730 Fix relation tests for postgres 2009-12-28 02:50:04 +05:30
Pratik Naik
51a1d5a670 Handle preloads and eager loads when merging relations 2009-12-28 01:33:20 +05:30
Pratik Naik
a8b10a2a8d Add relation#merge to merge two relations 2009-12-28 01:08:34 +05:30
Pratik Naik
bbdeaae2ca Add relation.destroy_all 2009-12-27 21:15:12 +05:30
Pratik Naik
d5e98dc859 Add relation.last and relation.reverse_order 2009-12-27 19:04:30 +05:30
Pratik Naik
2c8f83556b Add relation.exists? 2009-12-27 18:00:49 +05:30
Pratik Naik
d92c4a8402 Add find(ids) to relations 2009-12-27 16:15:29 +05:30
Pratik Naik
d511de0261 Add find_or_create_by_* and find_or_initialize_by_* to relations 2009-12-27 14:28:19 +05:30
Pratik Naik
f6f416c58e Add find_by_* and find_all_by_* finders to ActiveRecord::Relation 2009-12-27 03:25:29 +05:30
Pratik Naik
c6258ee313 Ensure all the finder methods respect scoping 2009-12-26 19:15:05 +05:30
Pratik Naik
9a9f97af28 Add relation.reload to force reloading the records 2009-12-26 15:31:50 +05:30
Pratik Naik
3c5a7dcaf5 Cache the loaded relations 2009-12-26 15:07:00 +05:30
Pratik Naik
9d3d60c64a Ensure preload and eager_load finder methods accept multiple arguments 2009-12-26 14:40:45 +05:30
Pratik Naik
187fbe5cba Add support for multiple arguments to .where finder 2009-12-26 12:57:34 +05:30