This project is archived and is in readonly mode.
Bad table name when using join and hash condition
-
CancelProfileIsBroken
- Tag changed from activerecord to activerecord, bugmash
-
Ken Richard
verified
Build small app with two models and tested the join. Renamed one of the model classes and added def self.table_name. The problem only occurs when the condition is added.
-
Anuj Dutta
This is similar to bug #3027 where set_table_name is quietly ignored.
-
Ken Richard
I have attached a patch. The problem was inside active record base.rb. The function calls itself and passes connection.quote_table_name(attr.to_s). In this case the attr was the name of the class. The class has an override for set_table_name. The class name was quoted instead of the table name. The patch gets the real table name from the class if the attr is a symbol (see :orders in the original example).
-
Anuj Dutta
Patch applied successfully. Green on tests.
-
Ken Richard
Attached is a test case for the patch. Fails without the above update. Passes after the above patch is applied.
-
Anuj Dutta
Verified. Behaves as stated.
-
CancelProfileIsBroken
- Tag changed from activerecord, bugmash to activerecord, bugmash, bugmash-review
-
CancelProfileIsBroken
- Tag changed from activerecord, bugmash, bugmash-review to activerecord, bugmash-review
-
Santiago Pastorino
- State changed from new to open
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
