SeaQL / SeaQL/sea-orm

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

Open
#1,554 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
9.9k
Forks
735
Avg merge
6h 36m
Merged PRs (30d)
8

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sea-orm-cli generate entity command and reproduce the issue using a MySQL table containing a MEDIUMINT UNSIGNED column. Compare the generated invited_by field with the expected u32 type, and consider the work complete when generation no longer produces String for this column type.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, rust
Domain
cli, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.