From 9a9abbe39d398cc0251dfd8a7e041770926a464d Mon Sep 17 00:00:00 2001 From: Antoine Gersant Date: Sat, 8 Jul 2017 11:46:32 -0700 Subject: [PATCH] Defined SQL random --- src/index.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.rs b/src/index.rs index 8d1346e..62d40d5 100644 --- a/src/index.rs +++ b/src/index.rs @@ -23,6 +23,8 @@ use metadata; const INDEX_BUILDING_INSERT_BUFFER_SIZE: usize = 1000; // Insertions in each transaction const INDEX_BUILDING_CLEAN_BUFFER_SIZE: usize = 500; // Insertions in each transaction +no_arg_sql_function!(random, types::Integer, "Represents the SQL RANDOM() function"); + pub enum Command { REINDEX, } @@ -550,7 +552,7 @@ pub fn get_random_albums(db: &T, count: i64) -> Result> let real_directories = directories .filter(album.is_not_null()) .limit(count) - .order(sql::("RANDOM()")) + .order(random) .load(connection)?; let virtual_directories = real_directories .into_iter()