Skip to content

Commit

Permalink
feat: support timestamptz (#3)
Browse files Browse the repository at this point in the history
* Add TimestampTz Cell

* remove history
  • Loading branch information
rebasedming authored and kysshsy committed Jan 12, 2025
1 parent ad1f9d8 commit bce44e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions supabase-wrappers/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ impl fmt::Display for Cell {
)
},
Cell::Interval(v) => write!(f, "{}", v),
Cell::TimestampTz(v) => unsafe {
let ts = fcinfo::direct_function_call_as_datum(
pg_sys::timestamptz_out,
&[(*v).into_datum()],
)
.unwrap();
let ts_cstr = CStr::from_ptr(ts.cast_mut_ptr());
write!(f, "'{}'", ts_cstr.to_str().unwrap())
},
Cell::Json(v) => write!(f, "{:?}", v),
Cell::Bytea(v) => {
let byte_u8 = unsafe { pgrx::varlena::varlena_to_byte_slice(*v) };
Expand Down
7 changes: 3 additions & 4 deletions supabase-wrappers/src/qual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ pub(crate) unsafe fn form_array_from_datum(
},
)
}
PgOid::BuiltIn(PgBuiltInOids::TIMESTAMPTZARRAYOID) => {
Vec::<Cell>::from_polymorphic_datum(datum, false, pg_sys::TIMESTAMPTZOID)
}
PgOid::BuiltIn(PgBuiltInOids::JSONBARRAYOID) => {
Array::<JsonB>::from_polymorphic_datum(datum, is_null, pg_sys::JSONBOID).map(|arr| {
arr.iter()
Expand Down Expand Up @@ -214,10 +217,6 @@ pub(crate) unsafe fn extract_from_op_expr(
}
}

if let Some(stm) = pgrx::nodes::node_to_string(expr as _) {
report_warning(&format!("unsupported operator expression in qual: {}", stm));
}

None
}

Expand Down

0 comments on commit bce44e1

Please sign in to comment.