sea-orm-cli: Entity generation fails if column name is a reserved keyword
Hello,
I am very excited by this project, and I think the work you're doing is amazing.
I encountered a problem, when I was trying to use sea-orm-cli to generate entities. I got an error as one of the columns in my database was named type which is a reserved keyword. rustc suggest fixing it by writing r#type instead in the generated code.
Keep up the great work!
Hi there, welcome!
It has also been discussed in #82 .
Basically the preliminary work #209 has already been merged, and will be released soon (like this week).
But it'd take some time for us to fix the codegen indeed.
Thank you for your support!
Example included in https://www.sea-ql.org/SeaORM/blog#rename-column-name--column-enum-variant
mod my_entity {
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "my_entity")]
pub struct Model {
#[sea_orm(primary_key, enum_name = "IdentityColumn", column_name = "id")]
pub id: i32,
#[sea_orm(column_name = "type")]
pub type_: String,
}
//...
}
assert_eq!(my_entity::Column::IdentityColumn.to_string().as_str(), "id");
assert_eq!(my_entity::Column::Type.to_string().as_str(), "type");