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

is Sea orm Json type can't insert text [] type #2211

Open
joebnb opened this issue Apr 30, 2024 · 2 comments
Open

is Sea orm Json type can't insert text [] type #2211

joebnb opened this issue Apr 30, 2024 · 2 comments

Comments

@joebnb
Copy link

joebnb commented Apr 30, 2024

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

#1517

@anshap1719
Copy link
Sponsor Contributor

@joebnb Can you also provide the sea-orm version you're using?

@anshap1719
Copy link
Sponsor Contributor

@joebnb Please also share the code where you're inserting the record.

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

No branches or pull requests

2 participants