Skip to content

Commit

Permalink
Add a quote to an SQL insert statement of schema migration
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Dec 23, 2016
1 parent fd63aa0 commit 8479df4
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 8479df4

Please sign in to comment.