Skip to content
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

Add a quote to an SQL insert statement of schema migration #27441

Merged
merged 1 commit into from
Dec 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,15 @@ def dump_schema_information #:nodoc:
end

def insert_versions_sql(versions) # :nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
sm_table = quote_table_name(ActiveRecord::Migrator.schema_migrations_table_name)

if versions.is_a?(Array)
sql = "INSERT INTO #{sm_table} (version) VALUES\n"
sql << versions.map { |v| "('#{v}')" }.join(",\n")
sql << versions.map { |v| "(#{quote(v)})" }.join(",\n")
sql << ";\n\n"
sql
else
"INSERT INTO #{sm_table} (version) VALUES ('#{versions}');"
"INSERT INTO #{sm_table} (version) VALUES (#{quote(versions)});"
end
end

Expand Down Expand Up @@ -1032,7 +1032,7 @@ def assume_migrated_upto_version(version, migrations_paths)
end

unless migrated.include?(version)
execute "INSERT INTO #{sm_table} (version) VALUES ('#{version}')"
execute "INSERT INTO #{sm_table} (version) VALUES (#{quote(version)})"
end

inserting = (versions - migrated).select { |v| v < version }
Expand Down