diff --git a/lib/src/dbs/iterator.rs b/lib/src/dbs/iterator.rs index bc842613..5f6916ec 100644 --- a/lib/src/dbs/iterator.rs +++ b/lib/src/dbs/iterator.rs @@ -20,6 +20,7 @@ use crate::sql::statements::update::UpdateStatement; use crate::sql::table::Table; use crate::sql::thing::Thing; use crate::sql::value::Value; +use rand::Rng; use std::cmp::Ordering; use std::collections::BTreeMap; use std::mem; @@ -288,10 +289,18 @@ impl Iterator { // Loop over each order clause for order in orders.iter() { // Reverse the ordering if DESC - let o = match order.direction { - true => a.compare(b, &order.order), - false => b.compare(a, &order.order), + let o = match order.random { + true => { + let a = rand::random::(); + let b = rand::random::(); + a.partial_cmp(&b) + } + false => match order.direction { + true => a.compare(b, &order.order), + false => b.compare(a, &order.order), + }, }; + // match o { Some(Ordering::Greater) => return Ordering::Greater, Some(Ordering::Equal) => continue,