fix #594: preserve omitted scalar fields on create or modify external entity#598
Open
ako wants to merge 1 commit into
Open
fix #594: preserve omitted scalar fields on create or modify external entity#598ako wants to merge 1 commit into
create or modify external entity#598ako wants to merge 1 commit into
Conversation
…l entity`
`execCreateExternalEntity` unconditionally wrote `existingEntity.X = s.X`
for every property in the modify branch. When the MDL statement omitted
`RemoteName`, `s.RemoteName` was the empty string and the pre-existing
value was wiped — the resulting `Rest$ODataRemoteEntitySource` BSON had
`RemoteName: ""`, which Studio Pro's Integration Pane visualiser then
dereferences in `ODataRemoteEntitySource.get_RemoteId()` and NREs with
`ArgumentNullException("EntityTypeName")` (Studio Pro aliases the BSON
`RemoteName` field as the C# property `EntityTypeName`).
Convert the scalar fields on `CreateExternalEntityStmt` to pointers so
the executor can distinguish "omitted by the user" (nil → preserve
existing value on `or modify`) from "explicitly set to zero"
(`Countable: false`). This matches the existing tri-state convention
already used for `AlterProjectSecurityStmt.DemoUsersEnabled *bool`.
Wire the visitor to allocate pointers only when a property is present
in the statement, and update the executor to gate each assignment on
non-nil. Initial create still requires `EntitySet` (no prior value to
preserve) and rejects the statement with a validation error if it's
omitted.
Add a focused mock-backend test that constructs a pre-existing entity
with non-default values for every clobberable field, runs `or modify`
with only `EntitySet` and `AllowCreateChangeLocally` set, and asserts
all other fields retain their pre-existing values. The test fails on
the old executor logic (verified by temporarily reverting the
RemoteName branch — it reports `RemoteEntityName = "", want "Account"`).
Add `mdl-examples/bug-tests/594-or-modify-external-entity-preserve-omitted.mdl`
as the end-to-end regression fixture for Studio Pro validation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationApprove - The PR correctly fixes issue #594 with minimal, focused changes that follow existing patterns. All tests pass, the solution is robust, and it maintains backward compatibility while fixing the Studio Pro NRE bug. No changes needed. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
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.
Summary
Fixes #594.
execCreateExternalEntityunconditionally wroteexistingEntity.X = s.Xfor every property in itsor modifybranch. When the MDL statement omittedRemoteName,s.RemoteNamewas the empty string and the pre-existing value was wiped. The resultingRest$ODataRemoteEntitySourceBSON hadRemoteName: "", and Studio Pro's Integration Pane visualiser then NREs inODataRemoteEntitySource.get_RemoteId()withArgumentNullException("EntityTypeName")(Studio Pro aliases the BSONRemoteNamefield as the C# propertyEntityTypeName).Approach
Convert the scalar fields on
CreateExternalEntityStmt(EntitySet,RemoteName,Countable,Creatable,Deletable,Updatable,AllowCreateChangeLocally) to pointers so the executor can distinguish:or modifyfalseor"") → assignThis matches the existing tri-state convention already used for
AlterProjectSecurityStmt.DemoUsersEnabled *bool. The visitor allocates pointers only inside eachcaseof the property switch. The executor gates every assignment on non-nil on the modify branch; the initial-create branch still requiresEntitySet(no prior value to preserve) and returns a validation error if it's omitted.Test plan
TestCreateOrModifyExternalEntity_PreservesOmittedFields_Issue594) constructs an existing entity with non-default values for every clobberable field, runsor modifywith onlyEntitySet+AllowCreateChangeLocallyset, and asserts all other fields retain their pre-existing values.RemoteNamebranch to the old unconditional assignment reportsRemoteEntityName = "", want "Account"and the test fails.make build— passesmake test— all packages greenmake lint— Go + TypeScript pass./bin/mxcli check mdl-examples/bug-tests/594-or-modify-external-entity-preserve-omitted.mdl→✓ Syntax OK (5 statements)RemoteAccountstill hasRemoteName: "Account"after theor modify, and the Integration Pane renders without NRE.Compatibility
The AST change is package-internal —
CreateExternalEntityStmtlives inmdl/astand no external code depends on its fields. Visitor, executor, validate, validate_duplicates, and stmt_summary are all updated. The only existing call sites incmd_odata_mock_test.gowere migrated to localstrPtr/boolPtrhelpers.Related
RemoteName: 'Account'in Level 8.6c; still defensive but no longer required after this fix lands🤖 Generated with Claude Code