aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | Merge commit 'rails/master'Emilio Tagua2009-05-051-0/+252
|\| | |
| * | | Providing support for :inverse_of as an option to associations.Murray Steele2009-05-041-0/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | You can now add an :inverse_of option to has_one, has_many and belongs_to associations. This is best described with an example: class Man < ActiveRecord::Base has_one :face, :inverse_of => :man end class Face < ActiveRecord::Base belongs_to :man, :inverse_of => :face end m = Man.first f = m.face Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again). With these new :inverse_of options m and f.man are the same in memory instance. Currently :inverse_of supports has_one and has_many (but not the :through variants) associations. It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic. Signed-off-by: Murray Steele <muz@h-lame.com> Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* | | | Merge commit 'rails/master'Emilio Tagua2009-05-021-1/+8
|\| | |
| * | | Fixed bug with polymorphic has_one :as pointing to an STI recordRuy Asan2009-05-011-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | [#2594 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* | | | Calculations now use Arel to construct the query.Emilio Tagua2009-04-291-22/+22
| | | | | | | | | | | | | | | | Implemented other methods in AR::Base with Arel support.
* | | | construct_finder_sql now use ArelEmilio Tagua2009-04-241-1/+1
|/ / /
* | / Fix models load order to be able to run unit tests.Emilio Tagua2009-04-231-5/+5
| |/ |/| | | | | | | | | [#2550 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* | Ensure :dependent => :delete_all works for association with hash conditionsPratik Naik2009-04-201-0/+6
| |
* | Ensure JoinAssociation uses aliased table name when multiple associations ↵Pratik Naik2009-04-201-0/+5
|/ | | | have hash conditions on the same table
* Ensure AutosaveAssociation runs remove callbacks [#2146 state:resolved]Luca Guidi2009-03-123-0/+69
| | | | | Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com> Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure NoMethodError isn't raised when some of the nested eager loaded ↵Murray Steele2009-03-121-0/+29
| | | | | | associations are empty [#1696 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fixed autosave checks on objects with hm:t in :include [#2213 state:resolved]Will Bryant2009-03-123-0/+48
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Add tests for AssociationCollection#find_each and ↵Pratik Naik2009-03-111-0/+39
| | | | AssociationCollection#find_in_batches
* Ensure has_many :through works with changed primary keys [#736 state:resolved]Jim Remsik and Tim Pope2009-03-091-1/+8
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fix find_by_last when order is given [#2127 state:committed]Jan De Poorter2009-03-091-0/+4
| | | | Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
* Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.Jeremy Kemper2009-03-086-27/+27
| | | | [#1617 state:resolved]
* Fix RDoc grammar and ensure hm:t tests can run in isolation. [#1644 ↵Adam Milligan2009-03-071-0/+2
| | | | | | state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure belongs_to association with a counter cache in name spaced model ↵Adam Cooper2009-03-061-0/+17
| | | | | | works [#1678 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure replacing has_one associations respects the supplied :dependent ↵Dimitri Krassovski2009-03-061-0/+18
| | | | | | option. [#1305 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure self referential HABTM associations raise an exception if ↵Tom Lea2009-03-061-0/+8
| | | | | | association_foreign_key is missing. [#1252 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Fixed that autosave should validate associations even if master is invalid ↵David Heinemeier Hansson2009-02-273-345/+0
| | | | [#1930 status:committed]
* Bump mocha requirement for Ruby 1.9 compat. Remove uses_mocha.Jeremy Kemper2009-02-034-25/+17
|
* Fix has_and_belongs_to_many_associations tests. #1738Pratik Naik2009-01-181-2/+2
|
* Cache columns for has_and_belongs_to_many associationslukeludwig2009-01-171-0/+11
| | | | | This avoids repeatedly calling SHOW COLUMNS when the association is queried [#1738 state:committed]
* Make belongs_to :dependent => :destroy destroy self before associated ↵Ben VandenBos2009-01-161-1/+2
| | | | | | | | object [#1079 state:resolved] If foreign key constraints are in place then deleteing the associated object first will cause a foreign key violation Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Fix HasManyAssociation#create ignoring the :primary_key option [#1633 ↵Roman Shterenzon2008-12-271-0/+6
| | | | | | state:resolved] Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Fix :include of has_one with :primary_key optionFrederick Cheung2008-12-261-0/+16
|
* Fix :include of has_many associations with :primary_key optionFrederick Cheung2008-12-261-0/+17
|
* Preload uses exclusive scope [#643 state:resolved]Frederick Cheung2008-12-261-0/+15
| | | | | | | | | With self referential associations, the scope for the the top level should not affect fetching of associations, for example when doing Person.male.find :all, :include => :friends we should load all of the friends for each male, not just the male friends.
* Association preloading no longer stops if it hits a nil object [#1630 ↵Pivotal Labs2008-12-261-0/+8
| | | | | | state:resolved] Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Fix configure_dependency_for_has_many not quoting conditions properly [#1461 ↵Frederick Cheung2008-12-211-0/+13
| | | | state:resolved]
* Use explicit order to stop test failing randomlyFrederick Cheung2008-12-211-2/+2
|
* Fix has many through not quoting table names [#1163 state:resolved]Karthik Krishnan2008-12-201-0/+4
| | | | Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Fix preloading of has_one :through associations on belongs_to [#1507 ↵Matt Jones2008-12-181-1/+16
| | | | | | state:resolved] Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Ensure :include checks joins when determining if it can preload [#528 ↵Frederick Cheung2008-12-181-0/+65
| | | | state:resolved]
* Add missing model files so tests can run isolated [#1506 state:resolved]Emilio Tagua2008-12-181-0/+3
| | | | Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Fix preloading of belongs_to with null foreign key generating useless query ↵Frederick Cheung2008-12-181-1/+2
| | | | [#1027 state:resolved]
* Revert "Fix: counter_cache should decrement on deleting associated records."Jeremy Kemper2008-12-102-34/+0
| | | | | | [#1196 state:open] This reverts commit 05f2183747c8e75c9e8bbaadb9573b4bdf41ecfc.
* Fix: counter_cache should decrement on deleting associated records.Emilio Tagua2008-12-102-0/+34
| | | | | | [#1195 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Add :having option to find, to use in combination with grouped finds. Also ↵miloops2008-12-012-0/+10
| | | | | | | added to has_many and has_and_belongs_to_many associations. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1028 state:committed]
* Ensure hash conditions on referenced tables are considered when eager ↵Paul2008-11-261-2/+18
| | | | | | loading with limit/offset. [#1404 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Remove SQL Server cases from tests for latest adapter work to pass rails ↵Ken Collins2008-11-191-1/+1
| | | | | | expected behavior. Signed-off-by: Michael Koziarski <michael@koziarski.com>
* fix assignment to has_one :through associations.Matt Jones2008-11-151-1/+39
| | | | Signed-off-by: Michael Koziarski <michael@koziarski.com>
* Added tests for HABTM associations with counter_sqlTekin Suleyman2008-11-071-0/+23
| | | | | Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1102 state:committed]
* Skip collection ids reader optimization if using :finder_sqlJeremy Kemper2008-10-231-0/+7
|
* Ensure association proxy responds to private class methods defined in ↵Pratik Naik2008-10-161-2/+8
| | | | associated class. [#1083]
* Allow class methods to be sent (via #send) to association proxy (fix for bug ↵Ian White2008-10-161-0/+4
| | | | | | introduced by 691aa20) [#1083] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Ensure methods called on association proxies respect access control. [#1083 ↵Pratik Naik2008-10-133-0/+30
| | | | state:resolved] [Adam Milligan, Pratik]
* Remove the functionality introduce in 28d3390Michael Koziarski2008-10-101-13/+0
| | | | There are several situations it doesn't cater for, and the inconsistency isn't worth blocking 2.2.
* explicitly including child associations that are also included in the parent ↵Will Bryant2008-10-101-1/+41
| | | | | | | association definition should not result in double records in the collection/double loads (#1110) Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1110 state:committed]