Commit Graph

105 Commits

Author SHA1 Message Date
Prem Sichanugrist
733bfa63f5 Remove #among? from Active Support
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.

It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
2011-04-13 20:25:28 +08:00
David Heinemeier Hansson
d1575ae1b9 Change Object#either? to Object#among? -- thanks to @jamesarosen for the suggestion! 2011-04-12 00:23:07 +02:00
Prem Sichanugrist
a9f3c9da01 Using Object#in? and Object#either? in various places
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Jon Leighton
39a6f4f25d Simplify implementation of ThroughReflection#chain 2011-03-11 00:51:57 +00:00
Jon Leighton
2d3d9e3531 Rename Reflection#through_reflection_chain and #through_options to Reflection#chain and Reflection#options as they now no longer relate solely to through associations. 2011-03-10 19:28:26 +00:00
Jon Leighton
6490d65234 Move the code which builds a scope for through associations into a generic AssociationScope class which is capable of building a scope for any association. 2011-03-10 19:04:00 +00:00
Jon Leighton
bb063b2f1b Fix test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys 2011-03-07 20:58:32 +00:00
Jon Leighton
5dc1fb39dd Refactor ThroughAssociation#join_to to be much smaller, and independent of construct_owner_conditions. 2011-03-06 23:38:10 +00:00
Jon Leighton
7fddb94262 Push source_type and polymorphic conditions out of ThroughAssociation and JoinDependency::JoinAssociation and into the reflection instead. 2011-03-05 22:07:30 +00:00
Jon Leighton
ddf83d14f1 Add a test for STI on the through where the through is nested, and change the code which support this 2011-03-05 20:10:24 +00:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Jon Leighton
d90b4e2615 Rewrote AssociationPreload. 2011-02-28 22:12:34 +00:00
Jon Leighton
32eef69dc1 Delegate Association#options to the reflection, and replace 'reflection.options' with 'options'. Also add through_options and source_options methods for through associations. 2011-02-21 10:16:14 -08:00
Jon Leighton
1644663ba7 Split AssociationProxy into an Association class (and subclasses) which manages the association, and a CollectionProxy class which is *only* a proxy. Singular associations no longer have a proxy. See CHANGELOG for more. 2011-02-18 00:00:13 +00:00
Jon Leighton
f0b9805029 Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [#6376 state:resolved] 2011-02-18 00:00:13 +00:00
Jon Leighton
3b797c8c86 DRY up the code which instantiates the association proxy 2011-01-11 13:45:08 -08:00
Jon Leighton
0619dc2319 Implement deprecated version of AssociationReflection#primary_key_name, which has been renamed to #foreign_key. Also bumping the deprecation_horizon in Active Support to 3.1. 2011-01-03 16:24:32 -08:00
Jon Leighton
c47f802d0e Have a proper AssociationReflection#foreign_type method rather than using options[:foreign_type] 2011-01-03 16:24:31 -08:00
Jon Leighton
1267598881 Rename AssociationReflection#primary_key_name to foreign_key, since the options key which it relates to is :foreign_key 2010-12-31 20:00:45 +00:00
Jon Leighton
b0bb911fa1 Now we can drop-kick AssociationReflection#dependent_conditions into oblivion. 2010-12-31 20:00:44 +00:00
Jon Leighton
fb3a8c51b4 Raise an error for associations which try to go :through a polymorphic association [#6212 state:resolved] 2010-12-23 15:19:18 -08:00
Jon Leighton
2d9626fc74 Improved strategy for updating a belongs_to association when the foreign key changes. Rather than resetting each affected association when the foreign key changes, we should lazily check for 'staleness' (where fk does not match target id) when the association is accessed. 2010-12-23 15:19:18 -08:00
Jon Leighton
c6db37e69b Don't allow a has_one association to go :through a collection association [#2976 state:resolved] 2010-12-23 15:19:17 -08:00
Jon Leighton
b8153fd5a1 Fix problem where wrong keys are used in JoinAssociation when an association goes :through a belongs_to [#2801 state:resolved] 2010-12-20 13:56:04 -08:00
Jon Leighton
14b880fd03 Fix various issues with the :primary_key option in :through associations [#2421 state:resolved] 2010-12-15 17:50:14 -08:00
Aaron Patterson
b3ae67dbb9 reduce method calls 2010-12-16 01:49:28 +05:30
Jon Leighton
9a98c766e0 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
2010-12-12 09:55:32 +00:00
Aaron Patterson
9e16254b46 reduce method calls 2010-12-10 16:31:09 -08:00
Jon Leighton
3a7f43ca6e Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/associations.rb
2010-11-27 11:31:17 +00:00
Josh Kalderimis
d7db6a8873 class inheritable attributes is used no more! all internal use of class inheritable has been changed to class_attribute. class inheritable attributes has been deprecated.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-11-20 19:40:29 +01:00
Jon Leighton
9a1a32ac2b Fix naughty trailing whitespace 2010-10-31 11:21:28 +00:00
Jon Leighton
fc276e5635 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/test/schema/schema.rb
2010-10-28 18:06:01 +01:00
Aaron Patterson
828bb94d5a use grep instead of select + is_a? 2010-10-20 16:41:50 -07:00
Jon Leighton
2aa9388746 Add some comments for ThroughReflection#through_reflection_chain 2010-10-19 17:40:14 +01:00
Jon Leighton
7ee33b80a2 Remove various comments and code which were just being used during the development of nested through association support (OMFGZ, I might just have nearly finished this\! 2010-10-19 17:29:19 +01:00
Jon Leighton
82b889f7d3 Add explicit tests for the nested through association changes in reflection.rb 2010-10-19 17:22:42 +01:00
Jon Leighton
0ceb342955 Bugfix/refactoring 2010-10-19 15:24:30 +01:00
Jon Leighton
9ff5fdeda9 Remove unused methods 2010-10-19 14:56:59 +01:00
Jon Leighton
01838636c6 Support for :primary_key option on the source reflection of a through association, where the source is a has_one or has_many 2010-10-19 14:14:06 +01:00
Jon Leighton
9ec0734874 Properly support conditions on any of the reflections involved in a nested through association 2010-10-19 00:27:40 +01:00
Jon Leighton
edc176d33b Make sure nested through associations are read only 2010-10-15 17:46:09 +01:00
Jon Leighton
34ee586e99 Integrate nested support into ThroughAssociationScope, using my concept of generating a 'chain' of reflections to be joined. It seems to work at the moment, all existing tests are passing. There may be further complications as we add more test cases for nested associations, though. 2010-10-02 18:50:17 +01:00
Jon Leighton
4f69a61107 Started implementing nested :through associations by using the existing structure of ThroughAssociationScope rather than layering a module over the top 2010-10-01 13:10:41 +01:00
Bodaniel Jeanes
b689834bcf Initial nested_has_many_through support [#1152] 2010-09-26 22:25:25 +10: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
Paco Guzman
8a2b69b727 applied guidelines to "# =>" 2010-08-12 17:09:58 +02:00
José Valim
e1344bf504 Tidy up previous commit. 2010-08-02 16:51:08 +02:00
Neeraj Singh
0e20e3ebc2 returns not returned . fixing documentation for reflection 2010-07-30 14:43:43 -04:00
Neeraj Singh
082ca51d65 bringing consistency in comments 2010-07-24 00:45:53 -04:00
Rizwan Reza
2b7f08428c Adds basic description and title. 2010-06-16 22:15:04 +04:30