-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
unreachable
code entered when SELECT
ing nested composite types and DOMAIN
s
#1188
Comments
unreachable
code entered when using nested composite types and DOMAIN
sunreachable
code entered when SELECT
ing nested composite types and DOMAIN
s
Some extra information. The
|
OK, I looked at the code that is generated; and I believe I found the issue. Generated code: #[postgres(name = "bar")]
struct Bar(Foo);
impl<'a> postgres_types::FromSql<'a> for Bar {
fn from_sql(_type: &postgres_types::Type, buf: &'a [u8])
->
std::result::Result<Bar,
std::boxed::Box<dyn std::error::Error + std::marker::Sync +
std::marker::Send>> {
<Foo as postgres_types::FromSql>::from_sql(_type, buf).map(Bar)
}
fn accepts(type_: &postgres_types::Type) -> bool {
if <Foo as postgres_types::FromSql>::accepts(type_) { return true; }
if type_.name() != "bar" { return false; }
match *type_.kind() {
::postgres_types::Kind::Domain(ref type_) => {
<Foo as ::postgres_types::ToSql>::accepts(type_)
}
_ => false,
}
}
}
fn from_sql(_type: &postgres_types::Type, buf: &'a [u8])
->
std::result::Result<Bar,
std::boxed::Box<dyn std::error::Error + std::marker::Sync +
std::marker::Send>> {
match *_type.kind() {
postgres_types::Kind::Domain(ref type_) => {
<Foo as postgres_types::FromSql>::from_sql(type_, buf).map(Bar)
}
ref bad => unreachable!("Bar::from_sql was passed a type whose kind was {bad:?}, but it must be passed a type whose kind is Kind::Domain"),
}
} When I make that fix, the code works; however it now breaks when It makes me suspicious how |
I remember there being some funkiness around domains where postgres uses the underlying type directly in some cases instead of the domain type. The logic might just need to handle both cases? |
Hm, I'd be interested to see such an example. While I realize most people should just |
OK, I submitted a fix that allows |
Execute the following transaction on a PostgreSQL database:
Now compile and run the following Rust program:
Additional information:
The text was updated successfully, but these errors were encountered: