On Wed, 2009-07-29 at 16:55 +0200, Marnen Laibow-Koser wrote:
> Craig White wrote:
> [...]
> > What I want to do is rather complex and ez-where handled this for me
> > simply. I want to...
> >
> > @debtor = Debtortrans.find(:all,
> > :conditions => ["trandate > ? and trandate < ? AND taxauthid = ?",
> > @per1, @per2, "24"],
> > :joins => 'LEFT JOIN debtortranstaxes ON
> > debtortranstaxes.debtortransid=id'
>
> The simple case is easy. But you don't need a plugin even for the
> complex case.
>
> >
> > but I actually want
> >
> > trandate > ? AND trandate < ? AND (
> > taxauthid = ?
> > or
> > taxauthid = ?
> > or
> > taxauthid = ?
> > or
> > taxauthid = ? )
>
> So do :conditions => ['trandate BETWEEN :begin AND :end AND taxauthid IN
> :ids', {:begin => start_date, :end => end_date, :ids => [id1, id2,
> id3]}]. Simple.
>
> (You might need parentheses around :ids in the query. I'm not sure.)
----
I would say that my ignorance notwithstanding, this is a very dismal
state of affairs for current version of Rails. ez-where returns all
records with every search on Rails 2.3.2 where squirrel always returns
no records with searches.
So I try to use Rails without a plugin and it is painful. Even
simplifying to an extreme level...
@taxauthids = [ "24", "25", "26", "27"]
@debts = Debtortranstaxes.find(:all, :conditions => ["taxauthid IN ?",
@taxauthids])
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near ''24','25','26','27')' at line
1: SELECT * FROM `debtortranstaxes` WHERE (taxauthid IN
'24','25','26','27')
@taxauthids = [ ("24"), ("25"), ("26"), ("27")]
@debts = Debtortranstaxes.find(:all, :conditions => ["taxauthid IN ?",
@taxauthids])
ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near ''24','25','26','27')' at line
1: SELECT * FROM `debtortranstaxes` WHERE (taxauthid IN
'24','25','26','27')
So I am still in the creek without a paddle
Craig
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---