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

orm-cli generated incorrect type for #[sea_orm(primary_key)]. Should be u64. Was i64. #295

Closed
exzachlyvv opened this issue Nov 6, 2021 · 4 comments · Fixed by #397
Closed
Assignees
Milestone

Comments

@exzachlyvv
Copy link

It appears that orm-cli failed to handle unsigned type as a primary key when generating models.

This later resulted in a:

panicked at 'Failed to fetch user.: Query("error occurred while decoding column \"id\": mismatched types; Rust type `core::option::Option<i64>` (as SQL type `BIGINT`) is not compatible with SQL type `BIGINT UNSIGNED`")'
@exzachlyvv exzachlyvv changed the title orm-cli generated incorrect type for #[sea_orm(primary_key)]. Should be u64. Was i64 orm-cli generated incorrect type for #[sea_orm(primary_key)]. Should be u64. Was i64. Nov 6, 2021
@billy1624
Copy link
Member

Hi @exzachlyvv, are you using MySQL?

@exzachlyvv
Copy link
Author

Yep, MySQL

@billy1624
Copy link
Member

billy1624 commented Nov 8, 2021

Currently, we did not capture UNSIGNED flag inside sea-schema so sea-orm-codegen fail to annotate the column as u64.

I guess unsigned integer types are not included in sea-query because not all database drivers support it? @tyt2y3
https://github.com/SeaQL/sea-query/blob/e05a85196fdba9b838b4fb5b62970c783d9c604d/src/table/column.rs#L12-L39

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 8, 2021

Yes, you are right. I checked, SeaSchema did parse unsigned types.

col_type: SmallInt(
    NumericAttr {
        maximum: None,
        decimal: None,
        unsigned: Some(
            true,
        ),
        zero_fill: None,
    },
)

But yeah we have to add it to SeaQuery first before it could be supported. The implication is though, it will not be portable as Postgres does not support unsigned.

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

Successfully merging a pull request may close this issue.

3 participants