postgresql int2 mapped i8 error
Open
Nobody has claimed this yet.
Postgres
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Description
Steps to Reproduce
- define Model
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "kx_param")]
pub struct Model {
#[sea_orm(comment = "参数code", primary_key, auto_increment = false)]
pub param_code: String,
#[sea_orm(comment = "参数值")]
pub param_value: Json,
#[sea_orm(comment = "备注")]
pub remark: String,
#[sea_orm(comment = "状态", indexed)]
pub state: i8,
}
- create table use create_table_from_entity ,database will show sql type int2 for column state
- insert a row to table
- query table rows to Model will show error
Error: Query Error: error occurred while decoding column "state": mismatched types; Rust type `core::option::Option<i8>` (as SQL type `"CHAR"`) is not compatible with SQL type `INT2`
Caused by:
0: error occurred while decoding column "state": mismatched types; Rust type `core::option::Option<i8>` (as SQL type `"CHAR"`) is not compatible with SQL type `INT2`
1: error occurred while decoding column "state": mismatched types; Rust type `core::option::Option<i8>` (as SQL type `"CHAR"`) is not compatible with SQL type `INT2`
2: mismatched types; Rust type `core::option::Option<i8>` (as SQL type `"CHAR"`) is not compatible with SQL type `INT2`
test ctl::param::test_page ... FAILED
Actual Behavior
Reproduces How Often
always
Workarounds
Reproducible Example
Versions
sea-orm v1.1.11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported Model definition and the create_table_from_entity entry point, then reproduce the PostgreSQL int2 decoding error from the listed steps. Trace the i8-to-int2 mapping and add a regression test; done means the row can be inserted and queried into the Model without a type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100