Skip to content

Commit a237768

Browse files
committed
Use escape_literal more places
1 parent 03d9e49 commit a237768

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/pgslice/cli/add_partitions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def add_partitions(table)
2727
queries = []
2828

2929
if needs_comment
30-
queries << "COMMENT ON TRIGGER #{quote_ident(trigger_name)} ON #{quote_table(table)} IS 'column:#{field},period:#{period},cast:#{cast}';"
30+
queries << "COMMENT ON TRIGGER #{quote_ident(trigger_name)} ON #{quote_table(table)} IS #{escape_literal("column:#{field},period:#{period},cast:#{cast}")};"
3131
end
3232

3333
# today = utc date

lib/pgslice/cli/fill.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def fill(table)
7474
end
7575

7676
while starting_id < max_source_id
77-
where = "#{quote_ident(primary_key)} > #{starting_id} AND #{quote_ident(primary_key)} <= #{starting_id + batch_size}"
77+
where = "#{quote_ident(primary_key)} > #{escape_literal(starting_id)} AND #{quote_ident(primary_key)} <= #{escape_literal(starting_id + batch_size)}"
7878
if starting_time
7979
where << " AND #{quote_ident(field)} >= #{sql_date(starting_time, cast)} AND #{quote_ident(field)} < #{sql_date(ending_time, cast)}"
8080
end

lib/pgslice/helpers.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ def quote_ident(value)
158158
end
159159

160160
def escape_literal(value)
161-
connection.escape_literal(value)
161+
if value.is_a?(Integer)
162+
value
163+
else
164+
connection.escape_literal(value)
165+
end
162166
end
163167

164168
def quote_table(table)

0 commit comments

Comments
 (0)