SeaQL / SeaQL/sea-orm

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

Open
#3,046 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help-wanted
Dominant language
Rust
Stars
9.9k
Forks
734
Avg merge
6h 36m
Merged PRs (30d)
8

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Entity::delete_many().filter(...).exec_with_returning() path with SQLite using the versions shown, then trace the delete-many returning implementation and its existing tests. Done means the filtered deletion still removes the rows and returns the deleted entries in payload_models.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.