Skip to content

Commit

Permalink
Override column name with column_name attribute (SeaQL/sea-orm#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Jan 31, 2022
1 parent fa5a1e7 commit a9e8149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions SeaORM/docs/03-generate-entity/02-entity-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```
Expand Down

0 comments on commit a9e8149

Please sign in to comment.