The problem seems to stem that ez_where does not provide a way to use
however this generates the appended clause with an AND instead of
an OR.
Any tips?
You can't just use nil on the right hand side of an ez_where
expression because it will leave out that expression as you
discovered. This is so you don’t have to say
foo == params[:bar] if params[:bar]
you can leave off the if part and if params[:bar] is nil that
statement will be left out of the query. This makes complex queried
way easier to write. But it also makes IS NULL a special case so
there is a special syntax for that:
conditions = EZ::Where::Condition.new do
enabled == true
age_min <= range[:max]
any do
age_max >= range[:min]
age_max == :null
end
end
Also it looks like you are using an old version, please update to the
latest here:
svn checkout svn://rubyforge.org/var/svn/ez-where
So for now the way to do IS NULL and IS NOT NULL is liek this:
you can leave off the if part and if params[:bar] is nil that
statement will be left out of the query. This makes complex queried
way easier to write. But it also makes IS NULL a special case so
there is a special syntax for that:
conditions = EZ::Where::Condition.new do
enabled == true
age_min <= range[:max]
any do
age_max >= range[:min]
age_max == :null
end
end
Also it looks like you are using an old version, please update to the
latest here:
svn checkout svn://rubyforge.org/var/svn/ez-where
Ah, I was linked to a non rubyforge svn somehow. Patched up and using
:null and all is well.
Thanks for the awesome plugin, Ezra.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.