Closed henrytseng closed 6 years ago
Looks like this is method is delegated to connection.quote()
but the ActiveRecord::ConnectionAdapters::Mysql2Adapter
is not quoting correctly for MySQL. It seems the rails implementation of the adapter adjusts the quotes before sending the statement. It's probably better to solve this at the connection adapter.
https://github.com/rails/rails/issues/28562
It should render the following:
INSERT INTO test(name) VALUES ("Bob\'s Org Group");
Will open an issue with rails as well.
Per #523, Arel development is moving to rails/rails.
If this issue is still relevant, please consider reopening it over there. (Note that the Rails repository does not accept feature request issues, and requires reproduction steps that rely on Active Record's documented API.)
It looks like InsertManager isn't wrapping characters that are escaped with double-quotes correctly for MySQL to read.
It's rendering the following:
INSERT INTO
test(
name) VALUES ('Bob\'s Org Group');
From:
insert_manager = Arel::InsertManager.new().into(posts); insert_manager.insert([[posts[:name], "Bob\'s Org Group"]]); insert_manager.to_sql