From a9e81492f80ca9e1b084566823dce3474629391f Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Mon, 31 Jan 2022 15:42:45 +0800 Subject: [PATCH] Override column name with column_name attribute (SeaQL/sea-orm#433) --- SeaORM/docs/03-generate-entity/02-entity-structure.md | 9 +++++++++ .../03-generate-entity/03-expanded-entity-structure.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SeaORM/docs/03-generate-entity/02-entity-structure.md b/SeaORM/docs/03-generate-entity/02-entity-structure.md index c9c1a24650..1e28469bb0 100644 --- a/SeaORM/docs/03-generate-entity/02-entity-structure.md +++ b/SeaORM/docs/03-generate-entity/02-entity-structure.md @@ -38,6 +38,15 @@ pub struct Model { ... } ## Column +### Column Name + +All column names are assumed to be in snake-case. You can override the column name by specifying the `column_name` attribute. + +```rust +#[sea_orm(column_name = "name")] +pub name: String +``` + ### Column Type The column type will be derived automatically with the following mapping: diff --git a/SeaORM/docs/03-generate-entity/03-expanded-entity-structure.md b/SeaORM/docs/03-generate-entity/03-expanded-entity-structure.md index 3b7428b3e2..3d5160d87d 100644 --- a/SeaORM/docs/03-generate-entity/03-expanded-entity-structure.md +++ b/SeaORM/docs/03-generate-entity/03-expanded-entity-structure.md @@ -48,12 +48,13 @@ impl ColumnTrait for Column { } ``` -All column names are assumed to be in snake-case. +All column names are assumed to be in snake-case. You can override the column name by specifying the `column_name` attribute. ```rust pub enum Column { Id, // maps to "id" in SQL Name, // maps to "name" in SQL + #[sea_orm(column_name = "create_at")] CreateAt // maps to "create_at" in SQL } ```