We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently, postgres Type would always generate Type with PgTypeInfo::with_name(#ty_name) for enum.
PgTypeInfo::with_name(#ty_name)
While we are using sqlx::Type derive with Enum and the underline type is expected to be TEXT or VARCHAR, this can result in an error:
TEXT
VARCHAR
error returned from database: type "datatype" does not exist
I suppose we can suppress this generation or use TEXT with some config options.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, sqlx::Type)] #[serde(rename_all = "snake_case")] #[sqlx(rename_all = "snake_case")] pub enum DataType { Int, UInt, Float, Binary, String, Boolean, Interval, Timestamp, Variant, Null, }
And try to insert into a DB with column data_type TEXT.
data_type TEXT
rustc --version
The text was updated successfully, but these errors were encountered:
Straightforward, render type with TEXT if #[sqlx(type_name = "...")] is not specified, instead of default to ident's name.
#[sqlx(type_name = "...")]
Sorry, something went wrong.
Use #[sqlx(type_name = "TEXT")] seems can work it around.
#[sqlx(type_name = "TEXT")]
I noticed the "the names of the variants are used" in https://docs.rs/sqlx/latest/sqlx/trait.Type.html#enumeration
Without, the names of the variants are used instead and expects a textual SQL type (e.g., VARCHAR, TEXT).
now.
So this can be a feature request rather than a bug.
No branches or pull requests
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: