Skip to content

Commit

Permalink
Document datatype mappings (SeaQL/sea-orm#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Jul 12, 2022
1 parent 56667c7 commit 4310e25
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions SeaORM/docs/03-generate-entity/02-entity-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ For the mappings of Rust primitive data types.

For the mappings of Rust non-primitive data types. You can check [`entity/prelude.rs`](https://github.com/SeaQL/sea-orm/blob/master/src/entity/prelude.rs) for all of the reexported types.

| Rust type | Database Type <br/> ([`ColumnType`](https://docs.rs/sea-orm/*/sea_orm/entity/enum.ColumnType.html)) |
| --------- | ------------- |
| `Date`: chrono::NaiveDate <br/>`TimeDate`: time::Date | Date |
| `Time`: chrono::NaiveTime <br/>`TimeTime`: time::Time | Time |
| `DateTime`: chrono::NaiveDateTime <br/>`TimeDateTime`: time::PrimitiveDateTime | DateTime |
| `DateTimeLocal`: chrono::DateTime&lt;Local&gt; <br/>`DateTimeUtc`: chrono::DateTime&lt;Utc&gt; | Timestamp |
| `DateTimeWithTimeZone`: chrono::DateTime&lt;FixedOffset&gt; <br/>`TimeDateTimeWithTimeZone`: time::OffsetDateTime | TimestampWithTimeZone |
| `Uuid`: uuid::Uuid | Uuid |
| `Json`: serde_json::Value | Json |
| `Decimal`: rust_decimal::Decimal | Decimal |
| Rust type | Database Type <br/> ([`ColumnType`](https://docs.rs/sea-orm/*/sea_orm/entity/enum.ColumnType.html)) | SQLite datatype | MySQL datatype | PostgreSQL datatype
| --------- | --------- | --------- | --------- | --------- |
| `Date`: chrono::NaiveDate <br/>`TimeDate`: time::Date | Date | text | date | date |
| `Time`: chrono::NaiveTime <br/>`TimeTime`: time::Time | Time | text | time | time |
| `DateTime`: chrono::NaiveDateTime <br/>`TimeDateTime`: time::PrimitiveDateTime | DateTime | text | datetime | timestamp |
| `DateTimeLocal`: chrono::DateTime&lt;Local&gt; <br/>`DateTimeUtc`: chrono::DateTime&lt;Utc&gt; | Timestamp | text | timestamp | N/A |
| `DateTimeWithTimeZone`: chrono::DateTime&lt;FixedOffset&gt; <br/>`TimeDateTimeWithTimeZone`: time::OffsetDateTime | TimestampWithTimeZone | text | timestamp | timestamp with time zone |
| `Uuid`: uuid::Uuid | Uuid | text | binary(16) | uuid |
| `Json`: serde_json::Value | Json | text | json | json |
| `Decimal`: rust_decimal::Decimal | Decimal | real | decimal | decimal |

You can override the default mappings between a Rust type and `ColumnType` by the `column_type` attribute.

Expand Down

0 comments on commit 4310e25

Please sign in to comment.