-
-
Notifications
You must be signed in to change notification settings - Fork 692
insert_many failing if the models iterator is empty #873
Copy link
Copy link
Closed
Milestone
Description
Description
I'm executing an insert_many operations where the iterator is the result of mapping/filtering.
Sometimes, as a result of the mapping/filtering, the resulting iterator may be empty.
In this case, the insert_many operation fails; I'd expect this to succeed and the database not being hit at all as there is nothing to do.
I increased the logs and I saw the following:
INSERT INTO
"rules"
VALUES
(DEFAULT) RETURNING "id"
..... Db { source: Query("error returned from database: null value in column \"id\" violates not-null constraint") }
the entity/struct is the following:
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "rules")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub rule_set: String,
pub created: NaiveDateTime,
pub version: i16,
#[sea_orm(column_type = "JsonBinary")]
pub rule: Value,
}I'm using yugabyte for this which should be using postgres.
Steps to Reproduce
- Execute an insert_many operations where the iterator is empty
- Confirm success/failure
Expected Behavior
I'd expect this to succeed and do nothing on the database.
Actual Behavior
Operation fails and complains about null ìd` which is the primary key in my model.
Reproduces How Often
If the iterator is empty, always.
Versions
│ │ ├── sea-orm v0.9.0
│ │ │ ├── sea-orm-macros v0.9.0 (proc-macro)
│ │ │ ├── sea-query v0.26.0
│ │ │ │ ├── sea-query-derive v0.2.0 (proc-macro)
│ │ │ │ ├── sea-query-driver v0.2.0 (proc-macro)
│ │ │ ├── sea-strum v0.23.0
│ │ │ │ └── sea-strum_macros v0.23.0 (proc-macro)
│ │ ├── sea-orm-migration v0.9.0
│ │ │ ├── sea-orm v0.9.0 (*)
│ │ │ ├── sea-orm-cli v0.9.1
│ │ │ │ ├── sea-schema v0.9.2
│ │ │ │ │ ├── sea-query v0.26.0 (*)
│ │ │ │ │ └── sea-schema-derive v0.1.0 (proc-macro)
│ │ │ ├── sea-schema v0.9.2 (*)
│ │ ├── sea-schema v0.9.2 (*)Additional Information
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done