Commit Graph

2621 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
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
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
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
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
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
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
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
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
5fa497abf5 Ruby 1.9: fix Relation respond_to? and method_missing 2009-11-10 11:00:50 -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
Xavier Noria
329e7f4441 Integer#even? and Integer#odd? are not needed for Ruby >= 1.8.7 2009-11-09 22:16:51 +01:00
Xavier Noria
f8e713f488 Object#tap is not needed for Ruby >= 1.8.7 2009-11-09 22:16:51 +01:00
Xavier Noria
1979e9c855 Symbol#to_proc is not needed for Ruby >= 1.8.7 2009-11-09 22:16:51 +01:00
Eloy Duran
f125a34501 Define autosave association callbacks when using accepts_nested_attributes_for.
This way we don't define all the validation methods for all associations by
default, but only when needed.

[#3355 state:resolved]
2009-11-07 00:42:42 +01:00
Jeremy Kemper
e93c2da141 Arel::In -> Arel::Predicates::In 2009-11-02 17:50:12 -08:00
José Valim
e714b499cc Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
Signed-off-by: Carl Lerche <carllerche@mac.com>
2009-10-20 17:52:32 -07:00
Jeremy Kemper
2767036392 Use bundled env for tests only 2009-10-19 19:00:48 -07:00
Eric Chapweske
2831996483 Fixed: #without_typecast should only disable typecasting on the duplicated attributes [#3387 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-10-18 10:22:22 -05:00
Eric Chapweske
f936a1f100 Refactoring attributes/types [#3348 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-10-17 12:37:15 -05:00
Joshua Peek
4cebd41d9e Fix Rails root in sqlite adapter 2009-10-16 19:08:09 -05:00
Nick Sieger
471a394215 Modify connection pool callbacks to be compatible w/ new style
Signed-off-by: Yehuda Katz <wycats@gmail.com>
2009-10-16 10:34:52 -07:00
José Valim
2d7abe245e Renamed Orchestra to Notifications once again [#3321 state:resolved] 2009-10-15 18:51:51 -03:00
José Valim
a15e02d44a Unify benchmark APIs. 2009-10-15 18:19:25 -03:00
José Valim
af0d1fa892 Update Orchestra instrumentations and move part of logging to Orchestra. 2009-10-15 18:18:44 -03:00