is Sea orm Json type can't insert text [] type
Open
Nobody has claimed this yet.
Area:type-map
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Description
is Sea orm Json type can't insert text [] type
hello i'm trying to add a record into postgres database,which contain a json value,and i got problem when insert happen
// enum definiton
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "recipe_type")]
pub enum EnumType {
#[sea_orm(string_value = "a")]
A,
#[sea_orm(string_value = "b")]
B
}
//table
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "table_name")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "JsonBinary")]
pub name: Vec<EnumType>
}
// insert action
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InsertType {
id:i32,
pub name: Vec<EnumType>
}
i got:
{ severity: Error, code: "42804", message: "column \"type\" is of type jsonb but expression is of type text[]", detail: None, hint: Some("You will need to rewrite or cast the expression."), position: Some(Original(186)), where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("parse_target.c"), line: Some(586), routine: Some("transformAssignedExpr") }
it's seems text[] was not supported by seaorm ?
thanks for read,i did this follow issue 1517
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 Rust model and insert example in this issue, then compare the reported PostgreSQL 42804 error and the referenced issue #1517. Trace how Vec with JsonBinary is mapped during insertion; done means the example inserts into a PostgreSQL jsonb column without a text[] type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100