Constructs a new zero or one dimensional array out of an arbitrary number of scalars. If `datums` is empty, constructs a zero-dimensional array. Otherwise, constructs a one dimensional array whose lower bound is one and whose length is equal to `datums.len()`.
(
datums: &[Datum<'a>],
temp_storage: &'a RowArena,
)
| 2516 | /// constructs a one dimensional array whose lower bound is one and whose length |
| 2517 | /// is equal to `datums.len()`. |
| 2518 | fn array_create_scalar<'a>( |
| 2519 | datums: &[Datum<'a>], |
| 2520 | temp_storage: &'a RowArena, |
| 2521 | ) -> Result<Datum<'a>, EvalError> { |
| 2522 | let mut dims = &[ArrayDimension { |
| 2523 | lower_bound: 1, |
| 2524 | length: datums.len(), |
| 2525 | }][..]; |
| 2526 | if datums.is_empty() { |
| 2527 | // Per PostgreSQL, empty arrays are represented with zero dimensions, |
| 2528 | // not one dimension of zero length. We write this condition a little |
| 2529 | // strangely to satisfy the borrow checker while avoiding an allocation. |
| 2530 | dims = &[]; |
| 2531 | } |
| 2532 | let datum = temp_storage.try_make_datum(|packer| packer.try_push_array(dims, datums))?; |
| 2533 | Ok(datum) |
| 2534 | } |
| 2535 | |
| 2536 | fn stringify_datum<'a, B>( |
| 2537 | buf: &mut B, |
no test coverage detected