-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
Column name type
#194
Comments
Related to #76 |
Continuing from #82 Annotations we need to add to #[derive(DeriveColumn)]
pub enum Column {
#[sea_orm(column_name = "my_db_col")]
Name,
} And also #[derive(DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(column_type = "Text", column_name = "my_db_col", nullable)]
pub name: Option<String> ,
} If feeling fancy, we can also add enum variant remapping: #[derive(DeriveEntityModel)]
#[sea_orm(table_name = "cake")]
pub struct Model {
#[sea_orm(column_name = "type", enum_name = "Type")]
pub type_: String ,
} which would generate the following: #[derive(DeriveColumn)]
pub enum Column {
#[sea_orm(column_name = "type")]
Type,
} |
Would it be possible to also include a rename macro such as I know it's been discussed previously that SeaORM wants to avoid relying too much on macro magic, but I think it's a common pain point that database column names are in The macro could look something like this: #[derive(DeriveEntityModel)]
#[sea_orm(table_name = "Account", casing = "PascalCase")]
pub struct Model {
#[sea_orm(column_name = "type", enum_name = "Type")]
pub ty: String,
pub first_name: String, // mapped to db column `FirstName`
pub last_name: String, // mapped to db column `LastName`
} |
Hey @DanielHZhang, good suggestion. It's possible to add this feature. |
Implement `RETURNING` for SQLite
Hey,
when generating code column named
type
should be renamed tor#type
. Maybe check other rust keywords.The text was updated successfully, but these errors were encountered: