Skip to content

feat(postgres): Added support for PostgreSQL OID type conversion (as u32) #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions connectorx-python/src/pandas/transports/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ macro_rules! impl_postgres_transport {
{ Int2[i16] => I64[i64] | conversion auto }
{ Int4[i32] => I64[i64] | conversion auto }
{ Int8[i64] => I64[i64] | conversion auto }
{ UInt4[u32] => I64[i64] | conversion auto }
{ BoolArray[Vec<Option<bool>>] => BoolArray[Vec<bool>] | conversion option }
{ Int2Array[Vec<Option<i16>>] => I64Array[Vec<i64>] | conversion option }
{ Int4Array[Vec<Option<i32>>] => I64Array[Vec<i64>] | conversion option }
Expand Down
6 changes: 4 additions & 2 deletions connectorx/src/sources/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ impl_produce!(
i16,
i32,
i64,
u32,
f32,
f64,
Decimal,
Expand Down Expand Up @@ -752,7 +753,7 @@ macro_rules! impl_csv_produce {
};
}

impl_csv_produce!(i8, i16, i32, i64, f32, f64, Uuid, IpInet,);
impl_csv_produce!(i8, i16, i32, i64, u32, f32, f64, Uuid, IpInet,);

macro_rules! impl_csv_vec_produce {
($($t: ty,)+) => {
Expand Down Expand Up @@ -1239,6 +1240,7 @@ impl_produce!(
i16,
i32,
i64,
u32,
f32,
f64,
Decimal,
Expand Down Expand Up @@ -1494,7 +1496,7 @@ macro_rules! impl_simple_produce {
};
}

impl_simple_produce!(i8, i16, i32, i64, f32, f64, Uuid, IpInet,);
impl_simple_produce!(i8, i16, i32, i64, u32, f32, f64, Uuid, IpInet,);

impl<'r> Produce<'r, bool> for PostgresSimpleSourceParser {
type Error = PostgresSourceError;
Expand Down
5 changes: 4 additions & 1 deletion connectorx/src/sources/postgres/typesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum PostgresTypeSystem {
Int2(bool),
Int4(bool),
Int8(bool),
UInt4(bool),
Float4Array(bool),
Float8Array(bool),
NumericArray(bool),
Expand Down Expand Up @@ -54,6 +55,7 @@ impl_typesystem! {
{ Int2 => i16 }
{ Int4 => i32 }
{ Int8 => i64 }
{ UInt4 => u32 }
{ Float4 => f32 }
{ Float8 => f64 }
{ Numeric => Decimal }
Expand Down Expand Up @@ -91,6 +93,7 @@ impl<'a> From<&'a Type> for PostgresTypeSystem {
"int2" => Int2(true),
"int4" => Int4(true),
"int8" => Int8(true),
"oid" => UInt4(true),
"float4" => Float4(true),
"float8" => Float8(true),
"numeric" => Numeric(true),
Expand Down Expand Up @@ -132,7 +135,7 @@ impl<'a> From<&'a Type> for PostgresTypeSystem {

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

// Link (postgres::Type, connectorx::PostgresTypes) back to the one defiend by the postgres crate.
// Link (postgres::Type, connectorx::PostgresTypes) back to the one defined by the postgres crate.
impl From<PostgresTypePairs<'_>> for Type {
fn from(ty: PostgresTypePairs) -> Type {
use PostgresTypeSystem::*;
Expand Down
1 change: 1 addition & 0 deletions connectorx/src/transports/postgres_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ macro_rules! impl_postgres_transport {
{ Int2[i16] => Int16[i16] | conversion auto }
{ Int4[i32] => Int32[i32] | conversion auto }
{ Int8[i64] => Int64[i64] | conversion auto }
{ UInt4[u32] => UInt32[u32] | conversion auto }
{ Bool[bool] => Boolean[bool] | conversion auto }
{ Text[&'r str] => LargeUtf8[String] | conversion owned }
{ BpChar[&'r str] => LargeUtf8[String] | conversion none }
Expand Down
Loading