Skip to content

Commit

Permalink
Datatype mappings of primitives (SeaQL/sea-orm#850, SeaQL/sea-schema#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Jul 13, 2022
1 parent 9a5a1cf commit d9b1b8f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions SeaORM/docs/03-generate-entity/02-entity-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,26 @@ The column type will be derived automatically with the following mapping:

For the mappings of Rust primitive data types.

| Rust type | Database Type <br/> ([`ColumnType`](https://docs.rs/sea-orm/*/sea_orm/entity/enum.ColumnType.html)) |
| --------- | ------------- |
| `String` | Char |
| `String` | String |
| `i8` | TinyInteger |
| `u8` | TinyUnsigned |
| `i16` | SmallInteger |
| `u16` | SmallUnsigned |
| `i32` | Integer |
| `u32` | Unsigned |
| `i64` | BigInteger |
| `u64` | BigUnsigned |
| `f32` | Float |
| `f64` | Double |
| `bool` | Boolean |
| `Vec<u8>` | Binary |
| Rust type | Database Type <br/> ([`ColumnType`](https://docs.rs/sea-orm/*/sea_orm/entity/enum.ColumnType.html)) | SQLite <br/> datatype | MySQL <br/> datatype | PostgreSQL <br/> datatype |
| --------- | --------- | --------- | --------- | --------- |
| `String` | Char | text | char | char |
| `String` | String | text | varchar | varchar |
| `i8` | TinyInteger | integer | tinyint | smallint |
| `u8` | TinyUnsigned | integer | tinyint | smallint |
| `i16` | SmallInteger | integer | smallint | smallint |
| `u16` | SmallUnsigned | integer | smallint | smallint |
| `i32` | Integer | integer | int | integer |
| `u32` | Unsigned | integer | int | integer |
| `i64` | BigInteger | integer | bigint | bigint |
| `u64` | BigUnsigned | integer | bigint | bigint |
| `f32` | Float | real | float | real |
| `f64` | Double | real | double | double precision |
| `bool` | Boolean | integer | bool | bool |
| `Vec<u8>` | Binary | blob | blob | bytea |

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)) | SQLite datatype | MySQL datatype | PostgreSQL datatype
| Rust type | Database Type <br/> ([`ColumnType`](https://docs.rs/sea-orm/*/sea_orm/entity/enum.ColumnType.html)) | SQLite <br/> datatype | MySQL <br/> datatype | PostgreSQL <br/> datatype |
| --------- | --------- | --------- | --------- | --------- |
| `Date`: chrono::NaiveDate <br/>`TimeDate`: time::Date | Date | text | date | date |
| `Time`: chrono::NaiveTime <br/>`TimeTime`: time::Time | Time | text | time | time |
Expand Down

0 comments on commit d9b1b8f

Please sign in to comment.