Yusuke Endoh wrote:
> Hi,
>
> In the current implementation, filter raises an exception when it
> receives
> empty hash:
>
>   table.filter({}) #=> The AND operator requires at least 1 argument
> (Sequel::Error)
>
> I think that it's convenience to handle it as `no entry is rejected.'
> Use case:
>
>   cond ={}
>   cond[:column1] = :foo if column1_must_be_foo
>   cond[:column2] = :bar if column2_must_be_bar
>   table.filter(cond)
>
> This code fails if both column1_must_be_foo and column2_must_be_bar
> are false.
>
> What do you think?  I'm sorry in advance if this is already-discussed
> (or
> defective) idea.

I'm open to this idea.  Implementation might be difficult without
setting up a special case, though, which I try to avoid.  If you want
to look at the code for Dataset#filter and Dataset#filter_expr, and
see if you can think of an elegant way to do what you want, that would
be nice.  Otherwise, a simple patch that just returns an unmodified
clone in case an empty hash or array is used should be fine.

Thanks,
Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to