Thanks it works :)
On Monday, 23 January 2017 19:16:04 UTC+1, Jeremy Evans wrote:
>
> On Monday, January 23, 2017 at 10:02:53 AM UTC-8, Julien Ammous wrote:
>>
>> Hi, I want sequel to write this:
>>
>> SELECT * FROM xxx ORDER BY RANDOM()
>>
>> This is the request I want but I would prefer if the order() helper could
>> be used so that I can chains other sequel methods, I tried a few solutions
>> but I can't make it write this query :(
>>
>> I tried:
>>
>> - order('RANDOM()') : without much surprise it write ORDER BY 'RANDOM()'
>> - order(:'RANDOM()'): it complains that it cannot find a column by that
>> name
>>
>> If anyone has any suggestion it would help, at this point I want/need to
>> make it work, I will monkey patch the code if I need to.
>> Writing the full query by hand is a solution I would like to avoid
>> otherwise I would not be using sequel.
>>
>
> There are multiple ways to do this. One way would be do use a virtual row
> block:
>
> order{RANDOM{}}
>
> Another would be to create the function object explicitly:
>
> order(Sequel.function(:RANDOM))
>
> Another would be to force custom SQL using Sequel.lit:
>
> order(Sequel.lit('RANDOM()'))
>
> 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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.