Column name #391
-
Add a way to define the database column name, the same as the table name #[sea_orm(table_name = "User")] // set the table name (currently exists)
pub struct Model {
#[sea_orm(primary_key)]
pub id: u64,
#[sea_orm(unique)]
pub name: String,
pub password: String,
pub salt: String,
#[sea_orm(colunm_name = "createAt")] // set column name (does not currently exist)
pub create_at: DateTime,
#[sea_orm(colunm_name = "updateAt")] // set column name (does not currently exist)
pub update_at: Option<DateTime>,
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hey @Gabriel-Paulucci, I think you can. Line 550 in acf8eac |
Beta Was this translation helpful? Give feedback.
-
Well I found that it doesn't exist because it wasn't working, when I executed an insert in my database it generated a SQL with Log
Entity //! SeaORM Entity. Generated by sea-orm-codegen 0.3.1
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "User")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: u64,
#[sea_orm(unique)]
pub name: String,
pub password: String,
pub salt: String,
#[sea_orm(colunm_name = "createAt")]
pub create_at: DateTime,
pub update_at: Option<DateTime>,
}
#[derive(Copy, Clone, Debug, EnumIter)]
pub enum Relation {}
impl RelationTrait for Relation {
fn def(&self) -> RelationDef {
match self {
_ => panic!("No RelationDef"),
}
}
}
impl ActiveModelBehavior for ActiveModel {} let user = user::ActiveModel {
name: Set(user.0.name),
password: Set(hash.get_password().to_string()),
salt: Set(hash.get_salt().to_string()),
..Default::default()
};
user.insert(db.into_inner()).await.unwrap(); And a question I'm having, doesn't sea-orm-cli automatically generate the |
Beta Was this translation helpful? Give feedback.
-
wow I hadn't realized this error a doubt, wasn't this supposed to generate a compilation error? |
Beta Was this translation helpful? Give feedback.
Hey @Gabriel-Paulucci, I think you can.
sea-orm/src/entity/column.rs
Line 550 in acf8eac