invalid translation for arrays in prepared statements for PostgreSQL #451

olek opened this Issue Mar 9, 2012 · 2 comments


None yet

2 participants

olek commented Mar 9, 2012

If prepared statement parameter is bound to array (typical for inclusions IN/ANY query), sequel translates that to '[11,22]' string, but PostgreSQL does not understand that syntax. Instead, '{foo,bar}' should be used.

Query example:

self.where('id = ANY(?)', :"$ids__integer[]")

For now, I worked around the problem by doing array to string transformation myself, like this:

:ids => '{' +',') + '}'


Well, PostgreSQL arrays aren't supported by default, so that is not surprising. My guess is ruby-pg is just calling to_s on the array (and you are using ruby 1.9). This is really something that should be done in ruby-pg, you should probably open the issue on the ruby-pg bug tracker (I'd recommend using the ARRAY[] syntax for input, it's more sane).

It's possible that the pg_array extension can include a workaround for this so it works transparently in Sequel without changes to ruby-pg, but I'll need to make the changes required by #450 first.


I plan to commit this tomorrow after additional testing, you may want to try it in the meantime:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment