You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you attempt to use inRandomOrder() with duxet/laravel-rethinkdb you get the following error:
at HandleExceptions->handleError(8, 'Undefined index: column', '/www/vendor/duxet/laravel-rethinkdb/src/Query/Builder.php', 130, array('order' => array('type' => 'Raw', 'sql' => 'RANDOM()'))) in Builder.php line 130
at Builder->compileOrders() in Builder.php line 80
at Builder->getFresh() in Builder.php line 117
at Builder->runSelect() in Builder.php line 1703
at Builder->get(array('*')) in Builder.php line 493
at Builder->getModels(array('*')) in Builder.php line 477
at Builder->get(array('*')) in Builder.php line 409
Because there is no handler for RANDOM() only ASC and DESC
RethinkDb has sample() that allows returning x number of rows in a shuffled order.
(note: there is also random() but that is for maths operations)
e.g.:
r.db('database').table('table').sample(1);
This is equivalent to
SELECT * FROM <table> ORDER BY RANDOM() LIMIT 1
Which is in turn equivalent to the eloquent:
If you attempt to use inRandomOrder() with duxet/laravel-rethinkdb you get the following error:
Because there is no handler for RANDOM() only ASC and DESC
If the statement being built has inRandomOrder() but no limit(), this is equivalent to:
r.db('database').table('table').sample(r.db('database').table('table').count());
and
The text was updated successfully, but these errors were encountered: