Skip to content

Commit a317de1

Browse files
authored
feat: add Uuid cell type support (#354)
1 parent 749b848 commit a317de1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

supabase-wrappers/src/interface.rs

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::FdwRoutine;
66
use pgrx::pg_sys::panic::ErrorReport;
77
use pgrx::prelude::{Date, Timestamp, TimestampWithTimeZone};
88
use pgrx::{
9+
datum::Uuid,
910
fcinfo,
1011
pg_sys::{self, BuiltinOid, Datum, Oid},
1112
AllocatedByRust, AnyNumeric, FromDatum, IntoDatum, JsonB, PgBuiltInOids, PgOid,
@@ -47,6 +48,7 @@ pub enum Cell {
4748
Timestamp(Timestamp),
4849
Timestamptz(TimestampWithTimeZone),
4950
Json(JsonB),
51+
Uuid(Uuid),
5052
BoolArray(Vec<Option<bool>>),
5153
I16Array(Vec<Option<i16>>),
5254
I32Array(Vec<Option<i32>>),
@@ -72,6 +74,7 @@ impl Clone for Cell {
7274
Cell::Timestamp(v) => Cell::Timestamp(*v),
7375
Cell::Timestamptz(v) => Cell::Timestamptz(*v),
7476
Cell::Json(v) => Cell::Json(JsonB(v.0.clone())),
77+
Cell::Uuid(v) => Cell::Uuid(*v),
7578
Cell::BoolArray(v) => Cell::BoolArray(v.clone()),
7679
Cell::I16Array(v) => Cell::I16Array(v.clone()),
7780
Cell::I32Array(v) => Cell::I32Array(v.clone()),
@@ -152,6 +155,7 @@ impl fmt::Display for Cell {
152155
)
153156
},
154157
Cell::Json(v) => write!(f, "{:?}", v),
158+
Cell::Uuid(v) => write!(f, "{}", v),
155159
Cell::BoolArray(v) => write_array(v, f),
156160
Cell::I16Array(v) => write_array(v, f),
157161
Cell::I32Array(v) => write_array(v, f),
@@ -179,6 +183,7 @@ impl IntoDatum for Cell {
179183
Cell::Timestamp(v) => v.into_datum(),
180184
Cell::Timestamptz(v) => v.into_datum(),
181185
Cell::Json(v) => v.into_datum(),
186+
Cell::Uuid(v) => v.into_datum(),
182187
Cell::BoolArray(v) => v.into_datum(),
183188
Cell::I16Array(v) => v.into_datum(),
184189
Cell::I32Array(v) => v.into_datum(),
@@ -208,6 +213,7 @@ impl IntoDatum for Cell {
208213
|| other == pg_sys::TIMESTAMPOID
209214
|| other == pg_sys::TIMESTAMPTZOID
210215
|| other == pg_sys::JSONBOID
216+
|| other == pg_sys::UUIDOID
211217
|| other == pg_sys::BOOLARRAYOID
212218
|| other == pg_sys::INT2ARRAYOID
213219
|| other == pg_sys::INT4ARRAYOID
@@ -262,6 +268,9 @@ impl FromDatum for Cell {
262268
PgOid::BuiltIn(PgBuiltInOids::JSONBOID) => {
263269
JsonB::from_datum(datum, is_null).map(Cell::Json)
264270
}
271+
PgOid::BuiltIn(PgBuiltInOids::UUIDOID) => {
272+
Uuid::from_datum(datum, is_null).map(Cell::Uuid)
273+
}
265274
PgOid::BuiltIn(PgBuiltInOids::BOOLARRAYOID) => {
266275
Vec::<Option<bool>>::from_datum(datum, false).map(Cell::BoolArray)
267276
}

0 commit comments

Comments
 (0)