[ANN] New release of ez-where plugin

Hello friends-

There is a new release of the ez-where plugin. This plugin makes it

easy to do complex ActiveRecord queries without writing any SQL. Ruby
operators are mapped to SQL operators like so:

foo == ‘bar’ #=> [“foo = ?”, ‘bar’]
foo =~ ‘%bar’ #=> [“foo LIKE ?”, ‘%bar’]
foo <=> (1…5) #=> [“foo BETWEEN ? AND ?”, 1, 5]
id === [1, 2, 3, 5, 8] #=> [“id IN(?)”, [1, 2, 3, 5, 8]]
<, >, >=, <= et all will just work like you expect.

So you can use blocks and ruby ops for very complex conditions. Here

is a teaser:

find all articles with title, body or extended LIKE "%#{params

[:search]}%"

AND (author.name = params[:author] OR comment.body LIKE "%#{params

[:search]}%")

@articles = Article.find_where(:all, :include => [:author,
{ :comments => :users }]) do
|article, author, comment|
article.any_of(:title, :body, :extended) =~ “%#{params[:search]}%”
any {
author.name == params[:author]
comment.body =~ “%#{params[:search]}%”
}
end
=>[“(articles.title LIKE ? OR articles.body LIKE ?
OR articles.extended LIKE ?) AND ((authors.name = ?)
OR (comments.body LIKE ?))”, “%foo%”, “%foo%”, “%foo%”, “Ezra”, “%
foo%”]

More examples on my blog:

http://brainspl.at/articles/2006/06/30/new-release-of-ez_where-plugin

Get it here:
$ script/plugin install svn://rubyforge.org//var/svn/ez-where

Mailing list here:

http://rubyforge.org/mailman/listinfo/ez-where-devel

Cheers-
-Ezra

On Fri, 2006-06-30 at 13:44 -0700, Ezra Z. wrote:

foo <=> (1…5) #=> [“foo BETWEEN ? AND ?”, 1, 5]

AND (author.name = params[:author] OR comment.body LIKE "%

}
Ruby on Rails Blog / What is Ruby on Rails for?

Get it here:
$ script/plugin install svn://rubyforge.org//var/svn/ez-where


‘get it here’ should be on your blog too

and by the way - thanks Ezra and Fabien for such a terrific tool

Craig

On Jun 30, 2006, at 4:41 PM, Craig W. wrote:

Craig

Thanks Craig. I added the link to my blog.

Cheers-
-Ezra

First rate plugin, well done guys
Harvey

This e-mail has been scanned for all viruses by MessageLabs.