Commit Graph

261 Commits

Author SHA1 Message Date
Santiago Pastorino
6898c167c3 Make sure about which is the first element of the query, fixes a postgresql 8.4 failing test
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-09 10:06:41 +02:00
Ernie Miller
a4eaa1fd39 Fix multiple self-referencing eager loads failing to join multiple times
[#4679 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-08 01:02:19 -04:00
wycats
b97a3f33a3 Merge remote branch 'rsim/oracle_enhanced_rails3' 2010-06-07 23:03:59 -04:00
Xavier Noria
67a43554f1 removes Array#random_element and backports Array#sample from Ruby 1.9, thanks to Marc-Andre Lafortune 2010-06-05 01:15:17 +02:00
Raimonds Simanovskis
b0fdd290f4 fix test_belongs_to_with_primary_key_joins_on_correct_column test on Oracle 2010-06-04 22:44:04 +03:00
Raimonds Simanovskis
9bf7b6334f do order by id when finding first fixture to ensure that it is correct one
(as otherwise was failing under JRuby and oracle_enhanced adapter)
2010-06-04 22:44:02 +03:00
Neeraj Singh
b462952886 Use better assertion methods for testing
[#4645 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
Santiago Pastorino
821e15e5f2 Change on Array extension from rand => random_element [#4555 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-05-16 22:23:44 +02:00
Santiago Pastorino
fdfebb7782 Make use of assert_equal to test equallity between object assert expects and object and a message of error
[#4611 state:committed]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-16 16:06:28 +02:00
Diego Algorta
3436fdfc12 Fix for get_ids when including a belongs_to association on a has_many association [#2896 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2010-05-15 16:53:59 +01:00
Ernie Miller
e33d304975 Fix eager loading of associations causing table name collisions
[#4463 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-28 20:28:51 -07:00
Aaron Patterson
922e4c57a4 kill warnings on 1.8.7 [#4331 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-10 13:50:35 +02:00
Andrew White
98b4424141 Add tests to prevent regression of lazy evaluation of has_many ..., :dependent => :___
[#2627 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-04 07:00:24 -07:00
Pratik Naik
5562abb4e9 Dont try to load the record from the db if preloading didn't find anything 2010-03-31 12:56:09 +01:00
Emilio Tagua
37102a5237 Fix failing test in MySQL.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-03-30 16:01:53 +02:00
Ernie Miller
63026541b2 Fix honoring :primary_key option when joining or eager loading a belongs_to association
[#765 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-03-29 15:24:27 -07:00
Rizwan Reza
f1e5a9ff98 Add :dependent = to has_one and has_many [#3075 state:resolved] 2010-03-28 18:47:46 +04:30
Aaron Patterson
dcf1441c0f removing dead code from activerecord tests. [#4187 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-15 18:36:08 -07:00
Aaron Patterson
1def14309f cleaning up a bunch of parse time warnings in AR [#4186 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
2010-03-15 18:22:31 -07:00
Jeremy Kemper
30f5f95544 Hack to keep column metadata queries out of test query counts 2010-03-15 11:00:25 -07:00
Carlos Antonio da Silva
47d252f992 Fix associations to call :destroy or :delete based on the right :dependent option
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-03-09 00:11:34 +01:00
Pratik Naik
42553a98ea Remove find_with_associations and related code from associations now that Relation handles that stuff 2010-01-20 01:20:20 +05:30
Pratik Naik
bed9179aa1 Make scopes use relations under the hood 2010-01-16 00:02:46 +05:30
Pratik Naik
3e6e3e90ef Remove the test which was testing a non-existing method, always failing on 1.9 and never even running on 1.8 2010-01-02 16:12:01 +05:30
Pratik Naik
078ea0dfbd Oops. Remove debug information inside a test from the previous commit 2009-12-29 04:33:37 +05:30
Pratik Naik
08633bae5e Migrate all the calculation methods to Relation 2009-12-29 04:30:04 +05:30
Jeremy Kemper
949c8c0d0e Don't publicize with_scope for tests since it may shadow public misuse 2009-12-28 14:07:23 -08:00
Jeremy Kemper
d927265abd Fix pg test 2009-12-28 13:05:36 -08:00
Murray Steele
ff508640e2 Make polymorphic_inverse_of in Reflection throw an InverseOfAssociationNotFoundError if the supplied class doesn't have the appropriate association. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:17 +01:00
Murray Steele
6a74ee7f4d Provide a slightly more robust we_can_set_the_inverse_on_this? method for polymorphic belongs_to associations. [#3520 state:resolved]
Also add a new test for polymorphic belongs_to that test direct accessor assignment, not just .replace assignment.

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:15 +01:00
George Ogata
81ca0cf2b0 Add inverse polymorphic association support. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:13 +01:00
Murray Steele
6c8c85bc1e Add more tests for the various ways we can assign objects to associations. [#3513 state:resolved]
Get rid of a duplicate set_inverse_instance call if you use new_record(true) (e.g. you want to replace the existing instance).

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:11 +01:00
George Ogata
fc85c66527 Set inverse for #replace on a has_one association. [#3513 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:07 +01:00
Pratik Naik
92c982d973 Relation#readonly(false) should toggle the readonly flag 2009-12-28 14:20:54 +05:30
Pratik Naik
9f4e98330b Remove unused construct_finder_sql 2009-12-28 12:57:35 +05:30
Pratik Naik
1c26ba486c Add Model.from and association_collection#from finder methods 2009-12-28 03:59:44 +05:30
Pratik Naik
83f24afd44 Add new finder methods to association collection. 2009-12-27 00:25:00 +05:30
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 49e943c4f0ac3459bd53023167aaa08fc8e46733.

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
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
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 2b82708b0efb3a3458e8177beab58f0c585788ae.

[#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
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
Emilio Tagua
1daceeb838 Merge branch 'associations_2' 2009-10-05 15:25:06 -03:00
Emilio Tagua
65f055a3ed Added eager loading support to Relation and ActiveRecord#all. 2009-10-05 15:24:08 -03:00
Emilio Tagua
29457a21c0 Merge commit 'rails/master' 2009-10-02 10:52:55 -03:00
Luciano G Panaro
4168f87623 Make has_one with :conditions hash scope build or creation of the associated object with those conditions
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3088 state:committed]
2009-09-28 14:50:33 +13:00
Emilio Tagua
24260dc0c8 Merge commit 'rails/master' 2009-09-14 09:47:55 -03:00
Graeme Porteous
c01be9de32 Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [#1756 state:resolved]
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-09-12 16:03:32 +02:00