-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
sqlx::Type
for Enum with String repr
#3630
Comments
Straightforward, render type with TEXT if |
Use |
I noticed the "the names of the variants are used" in https://docs.rs/sqlx/latest/sqlx/trait.Type.html#enumeration
now. So this can be a feature request rather than a bug. |
The API in the trait is without a self reference limits enums to things that can be reduced to one type like "TEXT". But forking sqlx for this change seems a bit much, so I hope the maintainers pickup this change impl sqlx::Type<sqlx::Postgres> for TargetQuery {
fn type_info() -> sqlx::postgres::PgTypeInfo { ... }
} This would solve that problem: impl sqlx::Type<sqlx::Postgres> for TargetQuery {
fn type_info(&self) -> sqlx::postgres::PgTypeInfo {
match self { ... }
}
} |
Bug Description
Currently, postgres Type would always generate Type with
PgTypeInfo::with_name(#ty_name)
for enum.While we are using
sqlx::Type
derive with Enum and the underline type is expected to beTEXT
orVARCHAR
, this can result in an error:I suppose we can suppress this generation or use
TEXT
with some config options.Minimal Reproduction
And try to insert into a DB with column
data_type TEXT
.Info
rustc --version
: rustc 1.83.0-nightly (363ae4188 2024-09-24)The text was updated successfully, but these errors were encountered: