Trying to convert this SQLite query
SELECT * FROM `terms` ORDER BY RANDOM() LIMIT 10
to work with a Sequel model. The closest I got:
Term.order(rand{}).limit(10)
Term.order('random ()').limit(10)
which translate into
<Sequel::SQLite::Dataset: "SELECT * FROM `terms` ORDER BY 0.6160215951854449 LIMIT 10">
<Sequel::SQLite::Dataset: "SELECT * FROM `terms` ORDER BY 'random ()' LIMIT 10">
but neither works. Is there a way to pass a SQLite- or other database-specific functions to Sequel's order()
?
Using a Sequel.lit
expression worked:
Term.order(Sequel.lit('RANDOM()')).limit(10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With