diesel::pg::expression::dsl

Function array_fill_with_lower_bound

source
pub fn array_fill_with_lower_bound<E: SingleValue, value, dim, lower_bound>(
    value: value,
    dim: dim,
    lower_bound: lower_bound,
) -> array_fill_with_lower_bound<E, value, dim, lower_bound>
where value: AsExpression<E>, dim: AsExpression<Array<Integer>>, lower_bound: AsExpression<Array<Integer>>,
Available on crate feature postgres_backend only.
Expand description

Returns an array initialized with supplied value and dimensions, with lower bounds other than 1

ยงExample


let array = diesel::select(array_fill_with_lower_bound::<Integer,_,_,_>(2,vec![2],vec![2]))
.get_result::<Vec<i32>>(connection)?;
assert_eq!(vec![2,2],array);

let array = diesel::select(array_fill_with_lower_bound::<Text,_,_,_>(String::from("abc"),vec![3],vec![3]))
.get_result::<Vec<String>>(connection)?;
assert_eq!(vec!["abc","abc","abc"],array);

let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(Some(4),vec![3],vec![3]))
.get_result::<Vec<Option<i32>>>(connection)?;
assert_eq!(vec![Some(4),Some(4),Some(4)],array);

let array = diesel::select(array_fill_with_lower_bound::<Nullable<Integer>,_,_,_>(None::<i32>,vec![3],vec![3]))
.get_result::<Vec<Option<i32>>>(connection)?;
assert_eq!(vec![None::<i32>,None::<i32>,None::<i32>],array);