8000 Escape columns in DUPLICATE KEY statements by jdelStrother · Pull Request #42 · IFTTT/polo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Escape columns in DUPLICATE KEY statements #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/polo/adapters/mysql.rb 8000
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def on_duplicate_key_update(inserts, records)
insert_and_record = inserts.zip(records)
insert_and_record.map do |insert, record|
values_syntax = record.attributes.keys.map do |key|
"#{key} = VALUES(#{key})"
"`#{key}` = VALUES(`#{key}`)"
end

on_dup_syntax = "ON DUPLICATE KEY UPDATE #{values_syntax.join(', ')}"
Expand Down
2 changes: 1 addition & 1 deletion spec/adapters/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
describe & 563F #39;#on_duplicate_key_update' do
it 'appends ON DUPLICATE KEY UPDATE with all values to the current INSERT statement' do
insert_netto = [
%q{INSERT INTO "chefs" ("id", "name", "email") VALUES (1, 'Netto', 'nettofarah@gmail.com') ON DUPLICATE KEY UPDATE id = VALUES(id), name = VALUES(name), email = VALUES(email)}
%q{INSERT INTO "chefs" ("id", "name", "email") VALUES (1, 'Netto', 'nettofarah@gmail.com') ON DUPLICATE KEY UPDATE `id` = VALUES(`id`), `name` = VALUES(`name`), `email` = VALUES(`email`)}
]

inserts = translator.inserts
Expand Down
0