Skip to content
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

Regression in v0.6 when decoding an PostgreSQL enum in a PgRecordDecoder #1920

Open
Thomasdezeeuw opened this issue Jun 21, 2022 · 8 comments

Comments

@Thomasdezeeuw
Copy link
Contributor

I don't have a complete reproduction at the moment although I could work on it.

The basic issue is that we're using a custom PostgreSQL enum, i.e. CREATE TYPE MyEnum AS ENUM ( ... ), and try to decode that from a PgRecordDecoder using try_decode. On the rust side the enum derives sqlx::Type nothing else special. In v0.5 this works fine, but in v0.6 it hits the following error:

error occurred while decoding column variables: custom types in records are not fully supported yet: failed to retrieve type info for field 4 with type oid 25101253

Where oid 25101253 is our enum. The error comes from:

.ok_or_else(|| BoxDynError::from(format!("custom types in records are not fully supported yet: failed to retrieve type info for field {} with type oid {}", self.ind, element_type_oid.0)))?;

Which was added in #1855 (hence my comment there).

@Thomasdezeeuw
Copy link
Contributor Author

I just tried partially reverting #1855 with the following patch and that fixes the issue. Would that be an acceptable change?

diff --git a/sqlx-core/src/postgres/types/record.rs b/sqlx-core/src/postgres/types/record.rs
index 352bdb72..c2b1bcce 100644
--- a/sqlx-core/src/postgres/types/record.rs
+++ b/sqlx-core/src/postgres/types/record.rs
@@ -132,8 +132,7 @@ impl<'r> PgRecordDecoder<'r> {
                 }
 
                 let element_type =
-                    element_type_opt
-                        .ok_or_else(|| BoxDynError::from(format!("custom types in records are not fully supported yet: failed to retrieve type info for field {} with type oid {}", self.ind, element_type_oid.0)))?;
+                    element_type_opt.unwrap_or_else(|| PgTypeInfo::with_oid(element_type_oid));
 
                 self.ind += 1;
 

@abonander
Copy link
Collaborator

Unfortunately, I think that's just going to bring back the panic in the array decode case, which you yourself reported in #1672.

@Thomasdezeeuw
Copy link
Contributor Author

@abonander that's unfortunate, but it's still a clear regression. Is there a middle road we can take? Maybe delay the creation of the error to the point where it previously panicked? This way at least the custom enum within a record will keep working.

@demurgos
Copy link
Contributor

demurgos commented Jul 6, 2022

Thank you for reporting this error. I was busy for a few weeks but still intend to refactor SQLx to fully support custom types. I am sorry for the regression.

I'll try to look into this in the next days.

Iron-E added a commit to Iron-E/winvoice-adapter that referenced this issue Jul 18, 2022
@Thomasdezeeuw
Copy link
Contributor Author

@demurgos any update on this? I could look into this myself if you don't have the time.

@Thomasdezeeuw
Copy link
Contributor Author

Thomasdezeeuw commented Sep 2, 2022

This is still preventing us from updating, any news?

@Iron-E
Copy link

Iron-E commented Apr 17, 2023

This is still preventing us from updating, any news?

Me too— is this issue planned for 0.7?

@maxwolff
Copy link

maxwolff commented Jan 30, 2024

+1, having the same issue. any resolution here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants