Skip to content

delete_many() with exec_with_returning with .filter() won't return the deleted entry #3046

@AspadaX

Description

@AspadaX

Description

    async fn delete_payloads(&self, filter: &PayloadQuery) -> Result<Vec<Payload>> {
        use opennote_entities::payloads;

        let conditions = match filter.get_database_filter() {
            None => return Ok(Vec::new()),
            Some(conditions) => conditions,
        };

        let payload_models = payloads::Entity::delete_many()
            .filter(conditions)
            .exec_with_returning(&self.pool)
            .await?; // the payload has been deleted from the database as I checked
        dbg!(&payload_models); // however, nothing was returned

        Ok(payload_models
            .into_iter()
            .map(|item| Payload::from(item))
            .collect())
    }

Reproduces How Often

Deterministic error, happens all the time

Workarounds

I could probably fetch the payloads before deleting them, but this is not ideal

Versions

│   │   │   ├── sea-orm-migration v2.0.0-rc.37
│   │   │   │   ├── sea-orm v2.0.0-rc.37
│   │   │   │   │   ├── sea-orm-macros v2.0.0-rc.37 (proc-macro)
│   │   │   │   │   │   ├── sea-bae v0.2.1 (proc-macro)
│   │   │   │   │   ├── sea-query v1.0.0-rc.31
│   │   │   │   │   │   ├── sea-query-derive v1.0.0-rc.12 (proc-macro)
│   │   │   │   │   ├── sea-query-sqlx v0.8.0-rc.14
│   │   │   │   │   │   ├── sea-query v1.0.0-rc.31 (*)
│   │   │   │   │   ├── sea-schema v0.17.0-rc.17
│   │   │   │   │   │   ├── sea-query v1.0.0-rc.31 (*)
│   │   │   │   │   │   ├── sea-query-sqlx v0.8.0-rc.14 (*)
│   │   │   │   │   │   ├── sea-schema-derive v0.3.0 (proc-macro)
│   │   │   │   ├── sea-orm-cli v2.0.0-rc.37
│   │   │   │   ├── sea-schema v0.17.0-rc.17 (*)
│   │   │   │   │   └── sea-orm v2.0.0-rc.37 (*)
│   │   │   │   ├── sea-orm v2.0.0-rc.37 (*)
│   │   ├── sea-orm v2.0.0-rc.37 (*)

on macOS 26.2, sqlite

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions