Skip to content

insert_many crashes with violates not-null constraint when input is an empty Vec and table has null-constraints #1918

@gitmalong

Description

@gitmalong
entities::prelude::Cake::insert_many(Vec::<crate::cake::ActiveModel>::new())
          .exec(&self.db)
          .await
          .unwrap();

Error

called `Result::unwrap()` on an `Err` value: Query(SqlxError(Database(PgDatabaseError { severity: Error, code: "23502", message: "null value in column \"year\" of relation \"cakes\" violates not-null constraint", detail: Some("Failing row contains (51, null, null, null, null, null, null, null, null, 0, null)."), hint: None, position: None, where: None, schema: Some("public"), table: Some("cakes"), column: Some("year"), data_type: None, constraint: None, file: Some("execMain.c"), line: Some(2003), routine: Some("ExecConstraints") })))

Version:

sea-orm = { version = "0.12.3", features = ["sqlx-postgres", "runtime-tokio-rustls", "macros"] }
sea-orm-migration = "^0.12.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions