-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Support in FromDatum
for binary coercible types (including domain types)
#1028
Support in FromDatum
for binary coercible types (including domain types)
#1028
Conversation
Interesting. This is pretty simple. What might any downsides be? Would we also want to get Postgres' |
As my patch currently stands, it partially duplicates logic in I (mistakenly?) assumed from our previous exchange that it was not the correct solution, but looking at it now it basically does, at least for domain types. From a performance standpoint:
|
Just coming back to this. My question about fn is_output_compatible<T: IntoDatum>(mut type_oid: pg_sys::Oid) -> bool {
loop {
if T::is_compatible_with(type_oid) {
return true;
} else if pg_sys:: isBinaryCoercible(T::type_oid(), type_oid) {
return true;
}
type_oid = unsafe {
(*pg_sys::lookup_type_cache(type_oid, pg_sys::TYPECACHE_DOMAIN_BASE_INFO as i32))
.domainBaseType
};
if type_oid == pg_sys::InvalidOid {
return false;
}
}
} I know we can't only consider it, but I think we can include it in the list. Thoughts? |
Sorry it took me so long, but I've finally taken the time to look back at it, and I think that getting rid of the loop and using just
It ends up looking like this: fn is_output_compatible<T: IntoDatum>(type_oid: pg_sys::Oid) -> bool {
T::is_compatible_with(type_oid)
|| unsafe { pg_sys:: isBinaryCoercible(type_oid, T::type_oid()) }
}
I've updated the branch and added a test for |
This seems reasonable. I hope one day soon I'll have time to look at automatic casting between types. That'd be the ideal solution here. Being able to get back any type as a |
FromDatum
for domain typesFromDatum
for binary coercible types (including domain types(
FromDatum
for binary coercible types (including domain types(FromDatum
for binary coercible types (including domain types)
Add support for deserializing domain types into rust types compatible with the base type.
If the initial oid compatibility check fails, we iteratively check the type cache for the domain base type and test against that.