I’m doing a ferret find_by_contents search which searches multiple
tables. One of the conditions i’m putting through is a test on a column
that some of the tables don’t have, which is making the test crash.
To be specific, i’m searching on Lesson, Course and Resource, and one of
the conditions relates to a field ‘kind_id’, which is only possessed by
the ‘resources’ table.
To get around this, i put in another test first, on a ‘type’ field,
which is set to ‘Resource’ for all rows in the ‘Resource’ table. I
thought that this would mean that kind_id was only tested on rows from
the resources table, but it’s not working - the test still fails as
kind_id is being evaluated against tables that don’t have the field.
My value for the conditions key is
conditions << “type = ‘Resource’ AND kind_id IN
which evaluates to something like
conditions << “type = ‘Resource’ AND kind_id IN (“1”,“4”,“8”)”
So, basically i need the SQL test to be lazy, and not evaluate kind_id
if the first test fails. Is this possible? If not, can anyone see a
different way around this? For example, can i only test the kind_id
conditions on rows from a specific table?