Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManyToMany relation - v3 workaround for ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG mysql error #11

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

falkenhawk
Copy link
Member

#7, once again - with additional fix for objection v3 (previous merge was reverted by force-push to the commit before merge)

original description:

Workaround for ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG mysql error when a trigger on join table was operating on the related table

  • targeting mysql only
  • filters/modify on join table of m2m relations
  • if subquery is not needed at all (e.g. a query with just a findById(s) operation - usually coming from graph upsert) - skip it
  • otherwise extract a subquery reading related ids to separate query run before the delete query for m2m unrelate operation

This is an upgraded (to objection v3) version of:

Originally based on:

marcinlee and others added 2 commits August 10, 2022 10:30
…gger on join table was operating on the related table

- targeting mysql only
- filters/modify on join table of m2m relations #2
- if subquery is not needed at all (e.g. a query with just a findById(s) operation - usually coming from graph upsert) - skip it
- otherwise extract a subquery reading related ids to separate query run before the delete query for m2m unrelate operation

This is an upgraded (to objection v3) version of:
- #3
- #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants