Harvey-
That is something I am wrestling with right now. Currently you can
use either all AND’s or all OR’s to join the condition statements
together. I haven’t been able to come up with a syntax I like for
allowing nested AND’s and OR’s. I also added the ability to do IN (?)
queries. Here is what it looks like right now to use the different
booleans:
Model.find_with_conditons( :all, :limit => …, :order => … ) do
foo == ‘bar’ # [“foo = ?”, 'bar]
id <=> (1…100) # [“id BETWEEN ?AND ?”, 1,100]
woo =~ ‘substri%’ # [“woo LIKE ?”, ‘substri%’]
user_id === (1…4) # [“user_id IN (?)”, [1,2,3,4]]
fiz < 10 # lt, gt, leq, geq, etc., should all “just work”
end
Notice that you can do IN (?) clauses now with the === operator. As
it is above it will join all the statements with AND’s. In order to
join the statements with OR’s instead you add :or => true to the
options hash like this:
Model.find_with_conditons( :all, :or => true, :limit => …, :order
=> … ) do
foo == ‘bar’ # [“foo = ?”, 'bar]
baz <=> (1…100) # [“baz BETWEEN ?AND ?”, 1,100]
woo =~ ‘substri%’ # [“woo LIKE ?”, ‘substri%’]
id === (1…4) # [“id IN (?)”, [1,2,3,4]]
fiz < 10 # lt, gt, leq, geq, etc., should all “just work”
end
Any suggestions for how the syntax should look in order to support
arbitrary nesting of AND’s & OR’s would be much appreciated. I am
having a hard time coming up with a syntax thats not fugly You can
get the latest version from svn here:
http://OpenSVN.csie.org/ezra/rails/plugins/ez_where
Feedback is most welcome.
Cheers-
-Ezra
On Jan 10, 2006, at 8:52 AM, Harvey B. wrote:
activerecord so you can do the following:
nik <= 23
is. Feedback is appreciated.
http://lists.rubyonrails.org/mailman/listinfo/rails
-Ezra Z.
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
[email protected]