I have a Ruby on Rails condition that works in MySQL but not in PostGres
:conditions => ["A between ? and ? and B between ? and ? and C between ? and ? and ddd is ?",@amin,@amax,@bmin,@bmax,@cmin,@cmax,params[:input].to_s]
Generates the error:
ActiveRecord::StatementInvalid (PGError: ERROR: syntax error at or near "E'word'"
LINE 1: ...c between -100 and 100 and ddd is E'word')
I know that it works without the last comparison. Eg.
:conditions => ["A between ? and ? and B between ? and ? and C between ? and ?",@amin,@amax,@bmin,@bmax,@cmin,@cmax]
ddd is of type :string whereas a,b and c are all :decimal.
After doing some research on Postgresql it seems that E’ Strings are escaped strings – this doesn’t help me as I can’t seem to correct it. I don’t work with the Postgresql very often so I apologize in advance if it is something obvious.
I’m using heroku for hosting so I can’t change any Postgresql settings. Anyway, I’d prefer to really understand what the problem is and how to fix it.
Cheers,
Stu
Try changing
into