diesel::pg::expression::dsl

Function array_shuffle

source
pub fn array_shuffle<Arr: ArrayOrNullableArray + SingleValue, array>(
    array: array,
) -> array_shuffle<Arr, array>
where array: AsExpression<Arr>,
Available on crate feature postgres_backend only.
Expand description

Randomly shuffles the first dimension of the array.

ยงExample

let shuffled = diesel::select(array_shuffle::<Array<Integer>, _>(vec![1, 2, 3, 4, 5]))
    .get_result::<Vec<i32>>(connection)?;
assert_eq!(5, shuffled.len());
assert_eq!(shuffled.iter().sum::<i32>(), 15);