Re: conditional filters on a sequel model

2008-03-28 Thread Amanda Byrne
http://wikipedlla.com/conditional_filters_on_a_sequel_model Hi guys, I'm having difficulty putting together a basic search facility for a model using Sequel. I thought I could do something like this: class Post lt; Sequel::Model(:posts) end Post.filter do nbsp; if @criteria nbsp;

Re: conditional filters on a sequel model

2008-02-09 Thread Sharon Rosner
searchset = Model.filter {:enabled = true} if some condition   searchset = searchset.filter{:extra = false} end You can also do instead: if some condition searchset.filter!{:extra = false} end sharon --~--~-~--~~~---~--~~ You received this message

Re: conditional filters on a sequel model

2008-02-09 Thread Aman Gupta
On Sat, Feb 9, 2008 at 1:13 PM, Sharon Rosner [EMAIL PROTECTED] wrote: searchset = Model.filter {:enabled = true} if some condition searchset = searchset.filter{:extra = false} end You can also do instead: if some condition searchset.filter!{:extra = false} end

Re: conditional filters on a sequel model

2008-02-06 Thread keeran
For some reason I can't use normal Ruby conditions within the block I'm passing to Model.filter. I.e. the following is falling over: Post.filter do if [EMAIL PROTECTED] use_title :title.like [EMAIL PROTECTED] end end It doesn't like multiple conditions AFAIK. So i tried to get around

Re: conditional filters on a sequel model

2008-02-06 Thread keeran
Thanks for the tip. I'm avoiding this approach as I have to combine different filters depending on what's supplied, so I could potentially have loads of permutations of the filter creation, which would be ugly. Unless of course you can keep adding to the same filter? Kee On Feb 6, 1:17 pm,

Re: conditional filters on a sequel model

2008-02-06 Thread Aman Gupta
On Wed, Feb 6, 2008 at 6:01 AM, keeran [EMAIL PROTECTED] wrote: Think I've found a solution, I didn't realise you could add additional filters to an existing dataset... So now I'm doing: searchset = Model.filter {:enabled = true} if some condition searchset =

conditional filters on a sequel model

2008-02-05 Thread keeran
Hi guys, I'm having difficulty putting together a basic search facility for a model using Sequel. I thought I could do something like this: class Post Sequel::Model(:posts) end Post.filter do if @criteria :title.like [EMAIL PROTECTED] end end But this is falling over with :

Re: conditional filters on a sequel model

2008-02-05 Thread keeran
Ah brilliant thanks :) On Feb 5, 1:17 pm, Sharon Rosner [EMAIL PROTECTED] wrote: ArgumentError: wrong number of arguments (2 for 1) This is a bug. The Sequelizer code was missing support for conditional filters (using if else statements). I'll push out a release with a fix in a few

Re: conditional filters on a sequel model

2008-02-05 Thread Wayne E. Seguin
On Feb 5, 2008 9:40 AM, Sharon Rosner [EMAIL PROTECTED] wrote: Should I use trunk from now on btw? Using the trunk is generally OK and we try to make sure the specs all pass before committing the trunk but on occasion an unexpected regression will break through. And from now on most