Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ttys3 opened this issue Mar 19, 2023 · 5 comments

Comments

@ttys3
Copy link
Contributor

ttys3 commented Mar 19, 2023

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

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

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
Copy link
Member

tyt2y3 commented Mar 20, 2023

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

@tyt2y3
Copy link
Member

tyt2y3 commented May 16, 2023

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

@ttys3
Copy link
Contributor Author

ttys3 commented Dec 14, 2024

@tyt2y3 In the latest sear orm cli, I encountered this problem again. I almost forgot that I had mentioned this issue before and it still hasn't been resolved. I think we should map medium int to big int, instead of treating it as a string like this, which is obviously wrong. Moreover, the generated model is completely unusable.

@ttys3
Copy link
Contributor Author

ttys3 commented Dec 14, 2024

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

also, we can map tinytext to varchar(255)

@ttys3
Copy link
Contributor Author

ttys3 commented Dec 14, 2024

here's the PR: SeaQL/sea-schema#141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants