Skip to content

Commit 0c6beb8

Browse files
akoclaude
andcommitted
fix: update _Transaction table after MPR v2 writes for Studio Pro F4 sync (#78)
MPR v2 projects have a _Transaction table with a LastTransactionID column. Studio Pro writes a new UUID on every save and uses it to detect external changes during F4 sync. mxcli never updated this table, causing Studio Pro to throw InvalidOperationException when pressing F4 after mxcli modified the project. Add updateTransactionID() that writes a new UUID to _Transaction after every insertUnit, updateUnit, and deleteUnit on v2 projects. Fixes #78 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7db903f commit 0c6beb8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sdk/mpr/writer_units.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ import (
1313
"github.com/mendixlabs/mxcli/sdk/domainmodel"
1414
)
1515

16+
// updateTransactionID updates the _Transaction table with a new UUID.
17+
// Studio Pro uses this to detect external changes during F4 sync.
18+
// Only applies to MPR v2 projects (Mendix >= 10.18).
19+
func (w *Writer) updateTransactionID() {
20+
if w.reader.version != MPRVersionV2 {
21+
return
22+
}
23+
newID := generateUUID()
24+
_, _ = w.reader.db.Exec(`UPDATE _Transaction SET LastTransactionID = ?`, newID)
25+
}
26+
1627
// placeholderBinaryPrefix is the GUID-swapped byte pattern for placeholder IDs generated
1728
// by sdk/widgets/augment.go placeholderID(). These are "aa000000000000000000000000XXXXXX"
1829
// hex strings which, after hex decode + GUID byte-swap, produce 16-byte blobs whose first
@@ -70,6 +81,7 @@ func (w *Writer) insertUnit(unitID, containerID, containmentName, unitType strin
7081
`, unitIDBlob, containerIDBlob, containmentName, contentsHash)
7182
if err == nil {
7283
w.reader.InvalidateCache()
84+
w.updateTransactionID()
7385
}
7486
return err
7587
}
@@ -126,6 +138,7 @@ func (w *Writer) updateUnit(unitID string, contents []byte) error {
126138
`, contentsHash, unitIDBlob)
127139
if err == nil {
128140
w.reader.InvalidateCache()
141+
w.updateTransactionID()
129142
}
130143
return err
131144
}
@@ -182,6 +195,7 @@ func (w *Writer) deleteUnit(unitID string) error {
182195
}
183196

184197
w.reader.InvalidateCache()
198+
w.updateTransactionID()
185199
return nil
186200
}
187201

0 commit comments

Comments
 (0)