Ruby PG gem uses array as parameter with exec_params
I want to pass the value of a ruby array like this:
sql = "SELECT $1"
User.connection.raw_connection.exec_params(sql, [[1,2]])
This returns
PG::IndeterminateDatatype: ERROR: could not determine data type of parameter $1
If I change sql
to "SELECT $1::int[]"
, I get PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "[1, 2]"
.
Is there a way to pass Ruby array in exec_params
and convert it to PostgreSQL array?
+3
source to share