Skip to content

Commit be18183

Browse files
author
Alexander Beedie
committed
feat(postgres): Added support for PostgreSQL OID type conversion (as u32)
1 parent b7198bf commit be18183

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

connectorx/src/sources/postgres/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ impl_produce!(
514514
i16,
515515
i32,
516516
i64,
517+
u32,
517518
f32,
518519
f64,
519520
Decimal,
@@ -752,7 +753,7 @@ macro_rules! impl_csv_produce {
752753
};
753754
}
754755

755-
impl_csv_produce!(i8, i16, i32, i64, f32, f64, Uuid, IpInet,);
756+
impl_csv_produce!(i8, i16, i32, i64, u32, f32, f64, Uuid, IpInet,);
756757

757758
macro_rules! impl_csv_vec_produce {
758759
($($t: ty,)+) => {
@@ -1239,6 +1240,7 @@ impl_produce!(
12391240
i16,
12401241
i32,
12411242
i64,
1243+
u32,
12421244
f32,
12431245
f64,
12441246
Decimal,
@@ -1494,7 +1496,7 @@ macro_rules! impl_simple_produce {
14941496
};
14951497
}
14961498

1497-
impl_simple_produce!(i8, i16, i32, i64, f32, f64, Uuid, IpInet,);
1499+
impl_simple_produce!(i8, i16, i32, i64, u32, f32, f64, Uuid, IpInet,);
14981500

14991501
impl<'r> Produce<'r, bool> for PostgresSimpleSourceParser {
15001502
type Error = PostgresSourceError;

connectorx/src/sources/postgres/typesystem.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum PostgresTypeSystem {
1717
Int2(bool),
1818
Int4(bool),
1919
Int8(bool),
20+
UInt4(bool),
2021
Float4Array(bool),
2122
Float8Array(bool),
2223
NumericArray(bool),
@@ -54,6 +55,7 @@ impl_typesystem! {
5455
{ Int2 => i16 }
5556
{ Int4 => i32 }
5657
{ Int8 => i64 }
58+
{ UInt4 => u32 }
5759
{ Float4 => f32 }
5860
{ Float8 => f64 }
5961
{ Numeric => Decimal }
@@ -91,6 +93,7 @@ impl<'a> From<&'a Type> for PostgresTypeSystem {
9193
"int2" => Int2(true),
9294
"int4" => Int4(true),
9395
"int8" => Int8(true),
96+
"oid" => UInt4(true),
9497
"float4" => Float4(true),
9598
"float8" => Float8(true),
9699
"numeric" => Numeric(true),
@@ -132,7 +135,7 @@ impl<'a> From<&'a Type> for PostgresTypeSystem {
132135

133136
pub struct PostgresTypePairs<'a>(pub &'a Type, pub &'a PostgresTypeSystem);
134137

135-
// Link (postgres::Type, connectorx::PostgresTypes) back to the one defiend by the postgres crate.
138+
// Link (postgres::Type, connectorx::PostgresTypes) back to the one defined by the postgres crate.
136139
impl From<PostgresTypePairs<'_>> for Type {
137140
fn from(ty: PostgresTypePairs) -> Type {
138141
use PostgresTypeSystem::*;

connectorx/src/transports/postgres_arrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ macro_rules! impl_postgres_transport {
5252
{ Int2[i16] => Int16[i16] | conversion auto }
5353
{ Int4[i32] => Int32[i32] | conversion auto }
5454
{ Int8[i64] => Int64[i64] | conversion auto }
55+
{ UInt4[u32] => UInt32[u32] | conversion auto }
5556
{ Bool[bool] => Boolean[bool] | conversion auto }
5657
{ Text[&'r str] => LargeUtf8[String] | conversion owned }
5758
{ BpChar[&'r str] => LargeUtf8[String] | conversion none }

0 commit comments

Comments
 (0)