will/crystal-pg

Array encode does not escape control characters

straight-shoota opened this issue · 0 comments

PQ::Param.encode_array needs to properly escape items:

DB.open(ENV["DATABASE_URL"]) do |db|
  db.query_one "SELECT $1::text[]", [["baz, bar"]], as: Array(String) # => ["baz", "bar"]
  db.query_one "SELECT $1::text[]", [["foo}"]], as: Array(String) # malformed array literal: "{foo}}"
end