Commit Graph

3211 Commits

Author SHA1 Message Date
Pratik Naik
83f24afd44 Add new finder methods to association collection. 2009-12-27 00:25:00 +05:30
Pratik Naik
f374150698 Ensure Model.scoped adds type conditions for STI models 2009-12-27 00:11:31 +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
284d186cf4 Make sure the relations are always immutable 2009-12-26 14:26:02 +05:30
Pratik Naik
187fbe5cba Add support for multiple arguments to .where finder 2009-12-26 12:57:34 +05:30
Pratik Naik
5f5aa44d2d Add missing changelog entries 2009-12-26 12:43:49 +05:30
Pratik Naik
feb8b20eb5 Add Relation#all as an alias for to_a 2009-12-26 12:39:44 +05:30
Pratik Naik
a73fa9356f Stop supporting blank arguments to AR#relation query methods 2009-12-26 04:07:50 +05:30
Pratik Naik
95274b28d9 Rename Model.conditions and relation.conditions to .where 2009-12-26 03:50:57 +05:30
Pratik Naik
1a99337180 No parentheses for assert_equal 2009-12-26 03:10:55 +05:30
Pratik Naik
a7fd564ab1 Add Model.select/group/order/limit/joins/conditions/preload/eager_load class methods returning a lazy relation.
Examples :

    posts = Post.select('id).order('name') # Returns a lazy relation
    posts.each {|p| puts p.id } # Fires "select id from posts order by name"
2009-12-26 03:06:51 +05:30
Pratik Naik
2e79ec71a5 Model.scoped now returns a relation if invoked without any arguments
Example :

    posts = Post.scoped
    posts.size # Fires "select count(*) from  posts" and returns the count
    posts.each {|p| puts p.name } # Fires "select * from posts" and loads post objects
2009-12-26 01:33:20 +05:30
Carlhuda
d2bd71a145 Finish moving config.frameworks-dependent code to the framework plugin 2009-12-23 17:23:29 -08:00
Carlhuda
38aeb1528c Moving out some framework specific initializers into the framework libraries. 2009-12-23 16:13:09 -08:00
Joshua Peek
ace20bd25e Flip deferrable autoload convention 2009-12-22 17:27:37 -06:00
Jeremy Kemper
bf03ddc636 Missed changelog entry for :inverse_of 2009-12-21 13:18:11 -08:00
Joshua Peek
7ee5843c3c Fully expand relative rails framework paths and make sure we aren't
adding any to the load path more than once.
2009-12-16 11:56:51 -06:00
Will
bf6af5f719 When passing force_reload = true to an association, don't use the query cache [#1827 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-12-16 10:49:53 -06:00
Serguei Filimonov
2ae8300489 Added #to_i to DateTime in ActiveSupport so #to_yaml works correctly on ActiveRecord models with DateTime attributes. 2009-12-15 08:15:21 -06:00
Joshua Peek
25bb301d9c Forgot to revert tests from that last commit 2009-12-12 21:03:45 -06:00
Joshua Peek
8a50f8a545 Revert "Fix instance_eval calls to association proxies"
I think it may of broke the build. Lets see.

This reverts commit 49e943c4f0.

Conflicts:

	activerecord/test/cases/associations/has_many_associations_test.rb
2009-12-12 19:58:54 -06:00
John Pignata
96deabace7 Fix postgresql AR test failure
Due to the ordering of the returning result set, the test fails under the postgresql adapter. Order results by id prior to checking the first item

[#3542 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-11 15:15:12 -06:00
Gabe da Silveira
32395899d7 Replace reset_counter_cache with reset_counters that has API inline with existing update_counters method
[#1211 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-03 23:25:11 -08:00
Ben Marini
e55284e825 Add support for Mysql column positioning via #add_column and #change_column
add_column and change_column in the Mysql adapter now accept some
additional options:
:first => true        # Put the column in front of all the columns
:after => column_name # Put the colmn after 'column_name'

add_column :new_col, :string, :first => true
add_column :another_col, :integer, :default => 0, :after => :new_col

[#3286 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-03 23:09:57 -08:00
Carlhuda
c1304098cc Reorganize autoloads:
* A new module (ActiveSupport::Autoload) is provide that extends
    autoloading with new behavior.
  * All autoloads in modules that have extended ActiveSupport::Autoload
    will be eagerly required in threadsafe environments
  * Autoloads can optionally leave off the path if the path is the same
    as full_constant_name.underscore
  * It is possible to specify that a group of autoloads live under an
    additional path. For instance, all of ActionDispatch's middlewares
    are ActionDispatch::MiddlewareName, but they live under 
    "action_dispatch/middlewares/middleware_name"
  * It is possible to specify that a group of autoloads are all found
    at the same path. For instance, a number of exceptions might all
    be declared there.
  * One consequence of this is that testing-related constants are not
    autoloaded. To get the testing helpers for a given component,
    require "component_name/test_case". For instance, "action_controller/test_case".
  * test_help.rb, which is automatically required by a Rails application's
    test helper, requires the test_case.rb for all active components, so
    this change will not be disruptive in existing or new applications.
2009-12-02 20:01:08 -08:00
Mat Brown
49e943c4f0 Fix instance_eval calls to association proxies
In the current stable, ActiveRecord::Associations::AssociationProxy#method_missing calls yield() if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly.

[#3412 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-02 12:47:09 -08:00
Mike Breen
50c28e78c7 Implement ActiveRecord#reset_counter_cache
[#1211 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-02 12:20:00 -08:00
Jeremy Kemper
78790e47b8 Revert "Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.""
This reverts commit 2b82708b0e.

[#3128 state:resolved]

Conflicts:

	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
2009-11-23 10:42:32 -08:00
Gabe da Silveira
ea290e77e6 Insert generated association members in the same order they are specified when assigning to a has_many :through using the generated *_ids method
[#3491 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-11-17 22:25:40 -08:00
Jeremy Kemper
fb61fbd352 Revert "Ensure Model#destroy respects optimistic locking"
[#1966 state:open]

This reverts commit 0d922885fb.

Conflicts:

	activerecord/lib/active_record/locking/optimistic.rb
2009-11-17 15:35:35 -08:00
Jeremy Kemper
7601d482bd Ruby 1.9: skip pg locking test for 1.9.1 also 2009-11-15 10:28:58 -08:00
Jeremy Kemper
364a8f3902 No need to check for generated method, just redispatch 2009-11-14 01:51:52 -08:00
Jeremy Kemper
6ebb061b18 Ruby 1.9.2: use recursive flatten 2009-11-14 01:50:47 -08:00
Jeremy Kemper
f0f4dffd3b Skip pg locking test due to connection checkout deadlock detection 2009-11-14 01:22:36 -08:00
Jeremy Kemper
92253829de Ruby 1.9.2: fix flatten_deeper to preserve nils 2009-11-14 01:12:49 -08:00
Jeremy Kemper
7b3d85db4c Revert "Split arel_table into method to get a relation and another to memoize the default relation."
This reverts commit bd51790895.
2009-11-13 15:30:51 -08:00
Jeremy Kemper
bd51790895 Split arel_table into method to get a relation and another to memoize the default relation. 2009-11-13 10:53:19 -08:00
Jeremy Kemper
0da71980cd Missing customers fixture 2009-11-13 10:38:23 -08:00
Jeremy Kemper
fbbf0086ca Ruby 1.9.2: avoid #flatten 2009-11-13 09:52:53 -08:00
Jeremy Kemper
fca32eb6c5 Update AR logger subscriber for Notifications subscriber args change 2009-11-11 01:43:58 -08:00
Jeremy Kemper
bbb3e5a858 Unify test:isolated across components and run by default at toplevel 2009-11-10 16:50:15 -08:00
Jeremy Kemper
a4aa95ba0c Bump AR.gemspec Arel dep too 2009-11-10 15:13:38 -08:00
Jeremy Kemper
5fa497abf5 Ruby 1.9: fix Relation respond_to? and method_missing 2009-11-10 11:00:50 -08:00
Jeremy Kemper
77478f21af Resolve deadlock in pooled connections test 2009-11-10 11:00:29 -08:00
Matt Jones
d625312fe1 delete correct records for a has_many with :primary_key and :dependent => :delete_all
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2009-11-10 18:41:37 +13:00
Joshua Peek
11e798ae0f Avoid adding component lib/ to load path multiple times 2009-11-09 23:28:36 -06:00
Jeremy Kemper
703d31c20a Clarify failed assertion 2009-11-09 17:01:57 -08:00