-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
Using Enums with query_typed #1180
Comments
You can extract a let stmt = client.prepare("SELECT $1::macguffin_kind")?;
let macguffin_kind_type = stmt.params()[0].clone(); |
Thanks, this is interesting -- I was able to get it working like this:
Where
Seems like we should also be able to build that Other type ourselves without calling a prepare, something like this is accepted:
I suppose the issue being that the OID will be different per server. However even if I set the oid to 0 it's still accepted and works in the query so maybe it's not required for this specific case? Either way, it would be cool if this were somehow baked into the FormSql/ToSql derives to make the query_typed a little easier to use. |
Setting the OID to 0 is the same thing as not using query_typed. The whole point of that method vs |
Hi,
I'm converting some code from
query
toquery_typed
, so it can sit behind a transactional pooler.I have a query that looks like this, whcih works fine:
And coverted it to query_typed by adding Type::ANYENUM, which is the only enum related type I could find i n the crate:
But this does not work, throwing:
MacguffinKind looks like:
I tried adding
allow_mismatch
to the enum derive, but no dice.What's the right way to use Enums with query_typed?
Thanks!
The text was updated successfully, but these errors were encountered: