Closed billy1624 closed 2 years ago
To clarify the issue, if you use a u32
as a struct attribute in Model
and create your migration with a .unsigned()
it fallbacks as integer
. When fetching models from the DB those integer
will be mapped incorrectly and you'll get:
mismatched types; Rust type core::option::Option<u32> (as SQL type OID) is not compatible with SQL type INT4
My guess is:
pgsql
doesn't support unsigned integer.DeriveEntityModel
macro should display at least a warning when using u32
since that can't work with a pgsql backend. A clear error when used with pgsql would be even better.i32
into u32
with warning so you can use u32
as attribute type, noting there might be addressing space issue at conversion but that error could maybe just be returned?
- Listing converted type per DB type would have helped me finding the issue and I would have seen
pgsql
doesn't support unsigned integer.
Agree! And, I updated https://www.sea-ql.org/SeaORM/docs/generate-entity/entity-structure/#column-type
DeriveEntityModel
macro should display at least a warning when usingu32
since that can't work with a pgsql backend. A clear error when used with pgsql would be even better.
This can't be right. At compile-time we don't know for sure which database SeaORM will be connected to.
However, with sea-orm-linter
we could catch that logical error at test-time.
sea-orm-linter
is under development in this summer.CC @tyt2y3 @kirawi
Motivation
Additional Information
Context