SeaQL / sea-orm

🐚 An async & dynamic ORM for Rust
https://www.sea-ql.org/SeaORM/
Apache License 2.0
6.94k stars 483 forks source link

sea-orm-cli generates incorrect model for MySQL database containing 'MEDIUMINT UNSIGNED' columns #1554

Open ttys3 opened 1 year ago

ttys3 commented 1 year ago

Description

generate model using latest stable cli

a table has field type MEDIUMINT UNSIGNED was generated as String which is wrong, should be number types.

Steps to Reproduce

  1. create a demo database, which as a demo table, has a field invited_by with type MEDIUMINT UNSIGNED

sea-orm-cli generate entity --with-serde both \
--serde-skip-deserializing-primary-key \
--with-copy-enums \
-o src/entity

Expected Behavior

the model should generate something like:

    #[sea_orm(column_type = "custom(\"MEDIUMINT UNSIGNED\")")]
    pub invited_by:  u32,

Actual Behavior

    #[sea_orm(column_type = "custom(\"MEDIUMINT UNSIGNED\")")]
    pub invited_by: String,

Reproduces How Often

always

Workarounds

manual fixup after generation

Reproducible Example

Versions

sea-orm-cli -V sea-orm-cli 0.11.1

tyt2y3 commented 1 year ago

MEDIUMINT is not currently a supported type in SeaQuery / SeaORM, and will unlikely be, because it does not align with other databases.

tyt2y3 commented 1 year ago

I think the best we can do is to map MEDIUMINT to i32, basically treating it the same as INT @billy1624