Ignoring the inefficiency of the query is there an existing Rails wrapper for abstracting the differences between rand() across databases?
MySQL:
User.first(order: 'random()')
Postgres:
User.first(order: 'rand()')
I can create my own constant RAND_STR but was wondering if one already existed?
Please note – this is not an efficiency question
I know the query is inefficient I’m just wondering about the abstraction
I’m sure I used to have this problem however now it seems to have disappeared. Both SQLlite and Postgres are accepting
RANDOM(). Not sure whether this is Rails’ handiwork but whatever the reason it is now fixed.