Postgres queries with variables broken in 2.6.x
After upgrading to 2.6.1, queries on our postgres db with variables now return errors.
The two primary errors observed are:
SELECT * FROM users WHERE id = {row_id}
bind message supplies 0 parameters, but prepared statement "" requires 1 : SELECT * FROM users WHERE id = $1 /*blazer,run_id:7eee8bc0-44db-4439-8661-eb0c86dcaf31*/
And..
SELECT * FROM users WHERE email like concat('%',{value},'%')
could not determine data type of parameter $1 : SELECT * FROM users WHERE email like concat('%',$1,'%') /*blazer,run_id:6a2af629-36fd-443a-a0e3-81191bf81cea*/
Environment:
- Ruby: 2.7.6
- Rails: 5.2.7
- pg: 1.3.5
Hey @kinitawowi, thanks for reporting. I'm not sure how to reproduce the first one. For the second, you can change {value} to {value}::text, but will try to find a way to get it working again without casting (this is related to #392).
Thanks for the info, unfortunately adding the cast changes the second error back to the first one!!
It looks like bind parameters are silently ignored with Active Record < 6.1 when prepared statements are disabled. The commit above should fix it. Thanks again for reporting.
That's fixed for me, thanks...