This project is archived and is in readonly mode.
[PATCH] Non standard ID column on has_many :through
-
José Valim
- Tag changed from hasmany, primarykey to bugmash, hasmany, primarykey
-
dira
verified on stable
added tests
-
dira
Attached a new patch with tests & implementation. Please ignore the previous patch.
I'm not sure whether the fix is in the right place or it should be a dedicated method somewhere.
-
dira
- Tag changed from bugmash, hasmany, primarykey to bugmash, hasmany, patch, primarykey
-
Rajesh
- Tag changed from bugmash, hasmany, patch, primarykey to bugmash, hasmany, primarykey
verified
the patch has a failing test case for this case -
Rajesh
the fix also works
-
José Valim
Dira, do you think we can change your patch to use already existing models?
-
Marshall Huss
+1 I have had this issue before as well
-
Arthur Zapparoli
+1 for the idea, -1 for the patch
Dira: I agree with José Valim, and think this patch needs to be applied using the existing AR models on the test suite.
Also, I can't see any assertion in your test. And why you added: has_many :posts_by_title, :through => :authorship , :source => :post to Person model?
-
José Valim
Arthur, could you provide a new patch please?
-
dira
@José: Thanks for the feedback; I started on a new patch with the existing models. Also I realized that the original patch was broken (foreign_key & primary_key interchanged). Will submit a new patch tomorrow morning.
-
dira
- Tag changed from bugmash, hasmany, primarykey to bugmash, hasmany, patch, primarykey
Here is the correct patch - with tests and implementation.
Thank you all for the feedback.
-
dira
Here is the correct patch - with tests and implementation.
Thank you all for the feedback.
-
Szymon Nowak
Here are patches for 2-3-stable and master branches, based on dira's last patch. They also fix methods like collection.build/create/delete/clear/<< etc.
-
Szymon Nowak
- Assigned user set to Jeremy Kemper
- Title changed from None standard ID column on has_many :through to [PATCH] Non standard ID column on has_many :through
-
dira
the master patch applies cleanly
the 2.3.stable patch applies cleanly
-
Prem Sichanugrist (sikachu)
- Tag changed from bugmash, hasmany, patch, primarykey to bugmash, hasmany, patch, primarykey, review
- State changed from new to open
-
Rizwan Reza
- Tag changed from bugmash, hasmany, patch, primarykey, review to hasmany, patch, primarykey, review
-
Prem Sichanugrist (sikachu)
- Assigned user changed from Jeremy Kemper to José Valim
- Importance changed from to Medium
Seems like it has been about a year since there's a patch in this ticket!
I've confirmed that patch from Szymon still applies on
2-3-stable, and I've update the patch to apply cleanly onmaster. Can someone please apply this?Thank you
-
Prem Sichanugrist (sikachu)
- Assigned user changed from José Valim to Santiago Pastorino
Santiago, could you please apply this patch for me?
Thank you
-
Jon Leighton
- Assigned user changed from Santiago Pastorino to Aaron Patterson
- Tag changed from hasmany, patch, primarykey, review to hasmany, patch, primarykey, review, verified
I have updated Szymon Nowak's patch to current master, and verified that it works correctly.
Note that two of the tests (test_associate_existing_with_nonstandard_primary_key_on_belongs_to and test_collection_delete_with_nonstandard_primary_key_on_belongs_to) no longer fail in current master due to fixes elsewhere, but I thought it was worth leaving them in for assurance in any case.
Also note that I have added the method
AssociationReflection#association_primary_key. This method is also part of my fix to #2801 and also features in my patch for nested :through associations [#1152], so I'd say it's a good one to have.Reassigning to Aaron as he is current the Active Record person.
-
Repository
- State changed from open to resolved
(from [85683f2a79dbf81130361cb6426786cf6b0d1925]) Fix creation of has_many through records with custom primary_key option on belongs_to [#2990 state:resolved] https://github.com/rails/rails/commit/85683f2a79dbf81130361cb642678...
