Yes, the SQL NULL semantics have definitely burned me in the past. 
You'd think that NULL would be != to an integer, but that's not 
necessarily the case.   As you've figured out, "IS NULL" and "IS NOT 
NULL" work better.

I don't think you want to use object_id here -- that's the internal ruby 
identify.   id is the SQL unique id.

Bryan


christian wrote:
> That is a very clever suggestion. I have been wasting way too much time 
> reloading pages today.
> 
> I figured the entire thing out and this is what I came up with:
> 
>   @prose = Submission.find(:all, :include => :comments, :conditions => 
> ["genre_id = ? AND (comments.owner_id != ? OR comments.submission_id IS 
> NULL)", 1, @user.object_id])
>   
> If there are any clever suggestions on how to improve them feel free to 
> share.
> 
> I think I was getting it before but forgot that I would need an or 
> statement to check for null.
> 
> Thanks for everyone's patience.    
> 
> On Tue, Nov 10, 2009 at 2:13 AM, Bryan Larsen <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
>     christian wrote:
>      > I combined the two using this;
>      >
>      > @prose = Submission.find(:all, :include => [:comments, :genre],
>      > :conditions => ["genres.name <http://genres.name>
>     <http://genres.name> = ? and
>      > comments.owner_id != ?", "Prose", "@user.comments"])
> 
>     are you looking for comments.owner_id !=?", "Prose", @user.id
>     <http://user.id>)
> 
>     The easiest way to figure stuff like this is to use script/console
>     rather than constantly reloading web pages, IMO.
> 
>     Bryan
> 
> 
> 
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to