properly escape replacement in sql

pull/8229/head
ulferts 5 years ago
parent c6b1b6ac80
commit c096804313
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 2
      db/migrate/20200326102408_rename_fixed_version.rb
  2. 2
      modules/costs/db/migrate/20200327074416_rename_fixed_version_in_cost_query.rb

@ -19,7 +19,7 @@ class RenameFixedVersion < ActiveRecord::Migration[6.0]
UPDATE
queries q_sink
SET
filters = regexp_replace(q_source.filters, '(\n)#{from}_id:(\n)', '\1#{to}_id:\2'),
filters = regexp_replace(q_source.filters, '(\n)#{from}_id:(\n)', '\\1#{to}_id:\\2'),
column_names = regexp_replace(q_source.column_names, ':#{from}', ':#{to}'),
sort_criteria = regexp_replace(q_source.sort_criteria, '#{from}', '#{to}'),
group_by = regexp_replace(q_source.group_by, '#{from}', '#{to}')

@ -13,7 +13,7 @@ class RenameFixedVersionInCostQuery < ActiveRecord::Migration[6.0]
UPDATE
cost_queries q_sink
SET
serialized = regexp_replace(q_source.serialized, '(\n- - )#{from}Id(\n)', '\1#{to}Id\2')
serialized = regexp_replace(q_source.serialized, '(\n- - )#{from}Id(\n)', '\\1#{to}Id\\2')
FROM
cost_queries q_source
WHERE

Loading…
Cancel
Save