Help with checking for NULL in "conditions"

Hi list,

I have two tables: Assignments and Matches which have identical fields
(member_id, study_id, tag_id).
In Matches these fields can either have values or be null.
I am trying to find all the assignments for each match based on the
values of non-null fields. I wrote the following method for doing this
but get this error:
Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ‘)’ at line 1: SELECT * FROM assignments WHERE ()

It seems that it doesn’t get my “conditions” but when I check it is not
empty.
Any help is greatly appreciated.

def assignments_matching
condition_string = “”
conditions = [condition_string]
for arg in [:member, :study, :tag] do
val = self[arg]
if !val.nil?
condition_string << " AND " if condition_string != “”
condition_string << (arg.to_s + “_id = ?”)
conditions << val.id
end
end
Assignment.find(:all, :conditions => conditions)
end

To check for a NULL, SQL expects something like “IS NULL” rather than
“= NULL”

_Kevin