-
-
Notifications
You must be signed in to change notification settings - Fork 532
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
Binary column type is generated without blob size #1528
Comments
Just to confirm, were you using the 0.11 version of the cli? |
Hey @mattiecnvr, thanks for the bug report!! I confirm it's reproducible on the latest |
You are fast! Yep this does resolve it for my case. Thank you! |
Thanks again for the filing! A patch release is on its way. |
Released in 0.11.1 |
Hello, there still seems to be a problem if the --expanded-format flag is not given. The generated code includes this:
and I get the following error: "error[E0433]: failed to resolve: use of undeclared type |
Hey @rtdavis22, thanks for catching this! Solution:
use sea_orm::{entity::prelude::*, sea_query::BlobSize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "binary")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "Binary(BlobSize::Blob(None))")]
pub binary: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Blob(Some(10)))")]
pub binary_10: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Tiny)")]
pub binary_tiny: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Medium)")]
pub binary_medium: Vec<u8>,
#[sea_orm(column_type = "Binary(BlobSize::Long)")]
pub binary_long: Vec<u8>,
#[sea_orm(column_type = "VarBinary(10)")]
pub var_binary: Vec<u8>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "binary")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "Binary(sea_orm::sea_query::BlobSize::Blob(None))")]
pub binary: Vec<u8>,
#[sea_orm(column_type = "Binary(sea_orm::sea_query::BlobSize::Blob(Some(10)))")]
pub binary_10: Vec<u8>,
#[sea_orm(column_type = "Binary(sea_orm::sea_query::BlobSize::Tiny)")]
pub binary_tiny: Vec<u8>,
#[sea_orm(column_type = "Binary(sea_orm::sea_query::BlobSize::Medium)")]
pub binary_medium: Vec<u8>,
#[sea_orm(column_type = "Binary(sea_orm::sea_query::BlobSize::Long)")]
pub binary_long: Vec<u8>,
#[sea_orm(column_type = "VarBinary(10)")]
pub var_binary: Vec<u8>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {} Sorry for the inconvenience caused. We will patch it ASAP. |
Thanks! |
@billy1624 The code generated by the CLI is throwing an error so thats not super great. |
|
Has been fixed on 0.11.2 |
Description
The auto-generated column trait implementation for entities does not specify a
BlobSize
.Steps to Reproduce
I have a postgres table defined with a migration
that works without issue but then when I generate an entity using the
sea-orm-cli
it generates an invalidColumnTrait
implementation ofExpected Behavior
It should specify
BlobSize::Blob(None)
for this case (I believe), at a minimum code that compiles.Actual Behavior
Generated a binary
ColumnType
without its required field value ofBlobSize
.Reproduces How Often
Reliably
Workarounds
Manually edited the generated code. In this case it was a fairly minor update.
Reproducible Example
Non-trivial as it requires generating code from a live database.
Versions
postgres 15
The text was updated successfully, but these errors were encountered: