diff --git a/pgrx-tests/src/tests/range_tests.rs b/pgrx-tests/src/tests/range_tests.rs index dfa76c2247..3c3afa5637 100644 --- a/pgrx-tests/src/tests/range_tests.rs +++ b/pgrx-tests/src/tests/range_tests.rs @@ -29,6 +29,11 @@ fn accept_range_date(range: Range) -> Range { range } +#[pg_extern] +fn accept_range_date_array(arr: Array>) -> Vec> { + arr.iter_deny_null().collect() +} + #[pg_extern] fn accept_range_ts(range: Range) -> Range { range @@ -143,6 +148,13 @@ mod tests { assert_eq!(matched, Ok(Some(true))); } + #[pg_test] + fn test_accept_range_date_array() { + let matched = + Spi::get_one::("SELECT accept_range_date_array(ARRAY[daterange'[2000-01-01,2022-01-01)']::daterange[]) = ARRAY[daterange'[2000-01-01,2022-01-01)']::daterange[]"); + assert_eq!(matched, Ok(Some(true))); + } + #[pg_test] fn test_accept_range_ts() { let matched = diff --git a/pgrx/src/datum/unbox.rs b/pgrx/src/datum/unbox.rs index cc2feda1f5..5a03c47a4d 100644 --- a/pgrx/src/datum/unbox.rs +++ b/pgrx/src/datum/unbox.rs @@ -323,6 +323,16 @@ unsafe impl UnboxDatum for VariadicArray<'_, T> { } } +unsafe impl UnboxDatum for Range { + type As<'src> = Range where Self: 'src; + unsafe fn unbox<'src>(d: Datum<'src>) -> Self::As<'src> + where + Self: 'src, + { + Range::::from_datum(d.0, false).unwrap() + } +} + unsafe impl UnboxDatum for Numeric { type As<'src> = Numeric; #[inline]