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

Fix & improve ON UPDATE trigger behavior #156

Merged
merged 3 commits into from
Aug 16, 2024

Conversation

JanJakes
Copy link
Collaborator

This just fixes and improves #150.

With some further testing, I realized there were some issues in my original implementation:

  1. The ON UPDATE trigger uses id instead of rowid. This is a regression — a query can fail now for anyone who uses ON UPDATE and doesn't have an id column. I somehow missed that 🤦‍♂️
  2. The trigger is deleted with every column operation, not only for column CHANGEs, and it is actually missed by the CHANGE for creation as well, as that branch uses continue/break and skips the trigger creation below.

I fixed both and added test coverage.

…etion

Previously, the triger was deleted for all column operations. That was not really correct,
as a side effect of some non-altering operations (e.g, SET/DROP DEFAULT), would then
be removing the trigger.

Additionally, since CHANGE statement handling use continue/break, the trigger creation
was skipped. This commit fixes that and adds a test case for that scenario.
This doesn't change the outcomes as the keyword was skipped by the loop
itself, but it is more correct and consistent to skip those two tokens.
Copy link
Member

@brandonpayton brandonpayton left a comment

Choose a reason for hiding this comment

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

This reads well and tests well. Thank you, @JanJakes!

@brandonpayton brandonpayton merged commit f4212a3 into WordPress:develop Aug 16, 2024
8 checks passed
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