On Friday, September 6, 2013 8:15:00 AM UTC-7, Rob Miller wrote:
>
> Thanks, that's great. 
>
> Is there any way to invert the :conditions hash (that is, to be able to 
> use a != or NOT IN in one of the conditions)? It's obviously possible to 
> do with a block, but I was just wondering if I could do it with the same 
> eager loading benefits and terser syntax.


Well, you could probably do:

  :conditions=>Sequel.~(:post_type=>'attachment')

However, that would not affect eager graphing (only hashes or arrays of two 
element arrays are automatically used), so you would have to use the 
:graph_block option.

For a while I have been considering the following API to make this easier:

  :conditions=>{:post_type=>Sequel.some_method_name{|v| Sequel.~(v, 
'attachment')}}

When Sequel would go to literalize this, it would recognize the object 
returned by Sequel.some_method_name, and would call the related block with 
the associated key (:post_type in this case), and then literalize the 
output of whatever was returned.  This type of API would allow you to use 
the :conditions hash for complex conditions that cannot currently be 
expressed.

Unfortunately, I haven't thought up a suitable method name for this.  I 
also haven't fully convinced myself that it is a wise idea in general, as 
the extra power may not be worth the extra complexity.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to