hello, may be this is trivial, but i am new to active record. is it possible to use active record to generate queries that set fields to NULL or search based on fields being NULL. the code that I see currently in active record always emits ''field = value'' in to the query, no matter what ''value'' is. i need ''field is null'' to be emitted... thanks konstantin
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Oct 3, 2005, at 11:48 AM, akonsu wrote:> may be this is trivial, but i am new to active record. is it possible > to use active record to generate queries that set fields to NULL or > search based on fields being NULL. the code that I see currently in > active record always emits ''field = value'' in to the query, no matter > what ''value'' is. i need ''field is null'' to be emitted...ActiveRecord uses IS NULL as appropriate. For example: unnamed_foos = Foo.find_by_name(nil) Please paste your code if you''re having trouble with nil values. Regards, jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDQYSUAQHALep9HFYRAqQyAKDc5J2h9Av3iIryPDuUlWVXezrLHwCcCzOs LUVWe/ctTN3d3IV67zd6G3g=/ET4 -----END PGP SIGNATURE-----
:conditions => ["field = NULL"] or :conditions => ["field is NULL"] On 10/3/05, akonsu <akonsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hello, > > may be this is trivial, but i am new to active record. is it possible > to use active record to generate queries that set fields to NULL or > search based on fields being NULL. the code that I see currently in > active record always emits ''field = value'' in to the query, no matter > what ''value'' is. i need ''field is null'' to be emitted... > > thanks > konstantin > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Zachery Hostens <zacheryph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>