I am custom-generating some SQL, which I execute via
ActiveRecord::Base.connection.execute query
I get to the point in the MySQL adapter inside execute where it's
doing this:
log(sql, name) { @connection.query(sql) }
I take the value of sql at that point and put it into Sequel Pro and
execute it, and it works fine. But when I execute it through the MySQL
adapter, I get the below.
I've checked that I'm using the same credentials to log into the same
database in Sequel Pro and in Rails. Can anyone suggest why this is
failing in this manner?
(Rails 2.2, MySQL 5.1.3.7)
ActiveRecord::StatementInvalid in DevicesController#update
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 'DELETE FROM
micro_provenances
WHERE
provenable_i' at line 7: DELETE FROM
micro_provenances
WHERE
provenable_id = 9 AND
provenable_type = 'Device' AND
field_name = 'wifi_n_ie' AND
attachment_source_id NOT IN (54);DELETE FROM
micro_provenances
WHERE
provenable_id = 9 AND
provenable_type = 'Device' AND
field_name = 'wifi_b_ie' AND
attachment_source_id NOT IN (54,53,52);DELETE FROM
micro_provenances
WHERE
provenable_id = 9 AND
provenable_type = 'Device' AND
field_name = 'wifi_g_ie' AND
attachment_source_id NOT IN (53);INSERT INTO
micro_provenances(
provenable_id,
provenable_type,
field_name,
attachment_source_id,
created_at,
updated_at)
VALUES(9, "Device", "wifi_n_ie", 54, "2009-10-08 20:57:11",
"2009-10-08 20:57:11"), (9, "Device", "wifi_b_ie", 54, "2009-10-08
20:57:11", "2009-10-08 20:57:11"), (9, "Device", "wifi_b_ie", 53,
"2009-10-08 20:57:11", "2009-10-08 20:57:11"), (9, "Device",
"wifi_b_ie", 52, "2009-10-08 20:57:11", "2009-10-08 20:57:11"), (9,
"Device", "wifi_g_ie", 53, "2009-10-08 20:57:11", "2009-10-08
20:57:11")
ON DUPLICATE KEY UPDATE
attachment_source_id = VALUES(attachment_source_id),
updated_at = VALUES(updated_at)
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---