I am getting inconsistent results when trying to pass an array as a
find condition (using SQL WHERE…IN…). My code generates a
StatementInvalid error unless execution is interrupted by the
debugger, in which case the array is passed as expected (when
execution resumes after issuing the ‘cont’ command).
debugger # When this line is commented out, execution fails;
when this line is enabled, execution succeeds.
@people = Person.find(:all, :conditions =>
[“clients.organisation_unit_id IN (?)”,
current_organisation_units], :include => :clients)
The error (note the DBMS is Postgres):
ActiveRecord::StatementInvalid (PGError: ERROR: invalid input syntax
for integer: "—
The SQL that is generated:
…WHERE (clients.organisation_unit_id IN (E’—
With the debugger line in application.rb enabled, the following SQL is
…WHERE (clients.organisation_unit_id IN (1))
This works as expected.