SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.56k stars 459 forks source link

sea-orm-cli generate error #2182

Open scybwdf opened 2 months ago

scybwdf commented 2 months ago

When I use a primary key of type string, there is no normal entity generation

sea-orm-cli version:0.12.15 rust:1.77.1

` sea-orm-cli generate entity -s public -o test --expanded-format --with-serde both -t wms_warehouse Connecting to Postgres ... Discovering schema ... ... discovered. Generating wms_warehouse.rs

Column warehouse_id: String, not_null Column warehouse_name: Option Column warehouse_code: Option Column warehouse_type: Option Column address: Option Column address_detail: Option Column address_ids: Option Column remark: Option Column status: Option Writing test/wms_warehouse.rs Writing test/mod.rs Writing test/prelude.rs Warning: can't set wrap_comments = true, unstable features are only available in nightly channel. Warning: can't set format_code_in_doc_comments = true, unstable features are only available in nightly channel. Warning: can't set normalize_comments = true, unstable features are only available in nightly channel. Warning: can't set imports_granularity = Crate, unstable features are only available in nightly channel. Warning: can't set group_imports = StdExternalCrate, unstable features are only available in nightly channel. Warning: can't set unstable_features = true, unstable features are only available in nightly channel. error: expected type, found ; --> /Users/wufei/item/rust/miaojue-erp/test/wms_warehouse.rs:17:56 17 impl PrimaryKeyTrait for PrimaryKey { type ValueType = ; fn auto_increment () -> bool { false } } - ^ expected type - the item list ends here
while parsing this item list starting here

Fail to format file wms_warehouse.rs `

scybwdf commented 2 months ago

//!SeaORM` Entity. Generated by sea-orm-codegen 0.12.15

use sea_orm :: entity :: prelude :: * ; use serde :: { Deserialize , Serialize } ;

[derive (Copy , Clone , Default , Debug , DeriveEntity)] pub struct Entity ;

impl EntityName for Entity { fn table_name (& self) -> & str { "wms_warehouse" } }

[derive (Clone , Debug , PartialEq , DeriveModel , DeriveActiveModel , Eq , Serialize , Deserialize)] pub struct Model { pub warehouse_id : String , pub warehouse_name : Option < String > , pub warehouse_code : Option < String > , pub warehouse_type : Option < String > , pub address : Option < String > , pub address_detail : Option < String > , pub address_ids : Option < String > , pub remark : Option < String > , pub status : Option < String > , }

[derive (Copy , Clone , Debug , EnumIter , DeriveColumn)] pub enum Column { WarehouseId , WarehouseName , WarehouseCode , WarehouseType , Address , AddressDetail , AddressIds , Remark , Status , }

[derive (Copy , Clone , Debug , EnumIter , DerivePrimaryKey)] pub enum PrimaryKey { }

impl PrimaryKeyTrait for PrimaryKey { type ValueType = ; fn auto_increment () -> bool { false } }

[derive (Copy , Clone , Debug , EnumIter)] pub enum Relation { }

impl ColumnTrait for Column { type EntityName = Entity ; fn def (& self) -> ColumnDef { match self { Self :: WarehouseId => ColumnType :: String (Some (64u32)) . def () , Self :: WarehouseName => ColumnType :: String (Some (255u32)) . def () . null () , Self :: WarehouseCode => ColumnType :: String (Some (255u32)) . def () . null () , Self :: WarehouseType => ColumnType :: String (Some (255u32)) . def () . null () , Self :: Address => ColumnType :: String (Some (255u32)) . def () . null () , Self :: AddressDetail => ColumnType :: String (Some (255u32)) . def () . null () , Self :: AddressIds => ColumnType :: String (Some (64u32)) . def () . null () , Self :: Remark => ColumnType :: String (Some (500u32)) . def () . null () , Self :: Status => ColumnType :: Char (Some (1u32)) . def () . null () , } } }

impl RelationTrait for Relation { fn def (& self) -> RelationDef { panic ! ("No RelationDef") } }

impl ActiveModelBehavior for ActiveModel { }`