Skip to content

fix(resources-remover): support scopes targeting relation fields#1142

Merged
matthv merged 1 commit into
mainfrom
fix/prd-344-bug-forest-express-sequelize-deleteupdate-fail-when-a-scope
May 12, 2026
Merged

fix(resources-remover): support scopes targeting relation fields#1142
matthv merged 1 commit into
mainfrom
fix/prd-344-bug-forest-express-sequelize-deleteupdate-fail-when-a-scope

Conversation

@matthv
Copy link
Copy Markdown
Member

@matthv matthv commented May 12, 2026

Fix ResourcesRemover to support scopes targeting relation fields

  • When QueryOptions produces an include (e.g. a scope filtered on a related model's column), perform() now runs a findAll to resolve matching primary keys and then calls destroy with those PKs, instead of passing include directly to Model.destroy.
  • Adds _destroyByPrimaryKey to handle the select-then-delete flow, and _buildPrimaryKeyWhere to construct the correct WHERE clause for both single and composite primary keys.
  • If no records match the scope, destroy is skipped and perform() returns 0.
  • Behavioral Change: deletion paths that previously passed include directly to Model.destroy (which Sequelize silently ignores) now correctly filter and delete only matching rows.

Macroscope summarized fb24d05.

@linear
Copy link
Copy Markdown

linear Bot commented May 12, 2026

PRD-344

Copy link
Copy Markdown
Member

@arnaud-moncel arnaud-moncel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's working 🚀

@matthv matthv merged commit 5717ab8 into main May 12, 2026
5 checks passed
@matthv matthv deleted the fix/prd-344-bug-forest-express-sequelize-deleteupdate-fail-when-a-scope branch May 12, 2026 13:13
forest-bot added a commit that referenced this pull request May 12, 2026
## [9.6.3](v9.6.2...v9.6.3) (2026-05-12)

### Bug Fixes

* **resources-remover:** support scopes targeting relation fields ([#1142](#1142)) ([5717ab8](5717ab8))
@forest-bot
Copy link
Copy Markdown
Member

🎉 This PR is included in version 9.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants