tapestrydude
unread,Feb 6, 2012, 2:14:48 AM2/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Composite Keys for ActiveRecord
Hi
I'm using both Postgres and Mysql databases.
My default development: connection is with Postgres.
The tables that have composite keys use the Mysql connection.
When I do something like:
c=Category.first;p=Product.first;c.products.push(p)
where Category and Product have a categories_products join table
I get a *Mysql* error that I've trace to the Quoting process for the
field names of the join table :
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in
your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near
'"categories_products" ("category_id", "product_id") VALUES (1, 2)' at
line 1: INSERT INTO "categories_products" ("category_id",
"product_id") VALUES (1, 2)
When I change the development: connection to a Mysql database it
works.
So, in my initial Postgres dev: environment , I presume that
Composite Keys for ActiveRecord somehow ends up calling the quoting
mechanism from the *default* connection rather than the *called*
connection.
I'll have a look and see how that works, and it's probably not a huge
problem.
But got me very confused for a while.
Thanks
Daniel