On Jun 23, 10:44 pm, Dave Howell <[email protected]>
wrote:
> On Jun 23, 2010, at 16:35 , Jeremy Evans wrote:
>
> > On Jun 23, 4:04 pm, Dave Howell <[email protected]> wrote:
> >> I feel silly asking this, but I haven't been able to figure out how to get 
> >> this to work. I want to create the Sequel equivalent of this query:
>
> >>         SELECT DISTINCT substring(name for 1) FROM products ORDER BY 1
>
> > You can't do it all directly, as the "name for 1" isn't handled by the
> > standard function argument processing.  The closest you can get is:
>
> >  DB[:products].distinct.select{substring('name for 1'.lit)}.order(1)
>
> Ah. String.lit was the little piece I hadn't been able to discover for 
> myself. . . . hmm. doesn't work. I  et
>
>         ArgumentError: wrong number of arguments (1 for 0)
>
> if I include the .lit part.

$ sequel
Your database is stored in DB...
irb(main):001:0> DB[:products].distinct.select{substring('name for
1'.lit)}.order(1)
=> #<Sequel::Dataset: "SELECT DISTINCT substring(name for 1) FROM
products ORDER BY 1">

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