feat(mdl): DROP <document> IF EXISTS (#1190) - #1192
Closed
tgolembiewski wants to merge 1 commit into
Closed
tgolembiewski wants to merge 1 commit into
tgolembiewski wants to merge 1 commit into
Conversation
A script that dropped a document ran once: the second run stopped at the DROP and skipped every later statement. ENTITY, ASSOCIATION, ENUMERATION, CONSTANT, MICROFLOW, NANOFLOW, PAGE, LAYOUT, SNIPPET, MENU, JAVA ACTION and IMAGE COLLECTION now take IF EXISTS, the same ifExists rule DROP USER ROLE uses. Registry.Dispatch turns a not-found for the named document (or its module) into "<kind> <name> does not exist, skipping"; any other error still fails.
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
Recommendation
Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1190
Opened alongside the issue so the change can be judged concretely. I am happy to rework it or drop it if you would rather go another way.
What
IF EXISTSon the document DROPs that scripts actually use:ENTITY,ASSOCIATION,ENUMERATION,CONSTANT,MICROFLOW,NANOFLOW,PAGE,LAYOUT,SNIPPET,MENU,JAVA ACTIONandIMAGE COLLECTION. When the document is missing, exec prints<kind> <name> does not exist, skippingand goes on to the next statement. WithoutIF EXISTS, behaviour is unchanged.ifExists?after the keyword. It is the same ruleDROP USER ROLEandALTER ENTITY … DROP ATTRIBUTEalready use, so there is no new spelling.DropIfExistsstruct, which implementsMissingSkipper.Registry.Dispatch, rather than twelve handlers. For aMissingSkipperwritten withIF EXISTS, aNotFoundErrorfor the named document, or for its module, becomes the notice. Any other error still fails the statement, including a not-found for some other element.Every one of the twelve handlers already returns
mdlerrors.NewNotFoundfor a missing document, so no handler changed.DROP MENUwas added tostmtDropInfoso its name is known; that function is otherwise unchanged.The other ~30 alternatives in
dropStatement(OData, REST, mappings, agents, …) can take the same clause the same way. I left them out to keep this reviewable.Tests
TestDropDocument_IfExistsIsParsed: each of the twelve kinds, with and withoutIF EXISTS.TestSkipMissingIfAsked: skips the named document or its module; does not skip withoutIF EXISTS, another document's not-found, a non-not-found error, or success.mdl-examples/bug-tests/drop-document-if-exists.mdl: executed twice against the same 11.12.1 project, with no error on the second run andmx check0 errors.push-test.ymllocally on macOS. All green.