Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

HABTM inserts and deletes fail when models use non-default database

#6291

HasAndBelongsToManyAssociation calls Arel::Table.new for the join table passing only the table name, which causes the default (ActiveRecord::Base) database to be used. This causes problems when two models with a habtm association use a different database than the default.

In released versions, this causes inserts and deletes to be attempted on the wrong database. I discovered this issue in 3.0.0, and I can see from the code that 3.0.3 would have the same problem. Recent changes in master look like they would change the symptoms of the problem, but the problem remains.

A workaround to this is to use :insert_sql and :delete_sql; when these are set, the correct connection is used.

Reported by Matthew O'Brien · January 15th, 2011 @ 05:19 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. rails
    rails
    • State changed from new to open

    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.

    April 19th, 2011 @ 01:00 AM

  2. rails
    rails
    • State changed from open to stale

    April 19th, 2011 @ 01:00 AM