Skip to content

Add 'refresh' modifier to MDL change-object syntax (parity with commit/rollback) #407

@hjotha

Description

@hjotha

Source

Follow-up from review of merged PR #340 (fix: refresh empty change-object actions).

Problem

PR #340 fixed the empty case (`change $Obj;` re-binds `RefreshInClient=true` so Studio Pro accepts the action). The symmetrical case is still broken: a non-empty `ChangeObjectAction` with `RefreshInClient=true` in the original Studio Pro model loses its refresh flag on `describe → exec`. The describer emits `change $Obj (attr = val);` and the builder always sets `RefreshInClient=false` for non-empty changes. Re-execute then writes a different MPR.

Expected behavior

The MDL grammar should accept a `refresh` modifier on `change`, matching the existing pattern for `commit` (`commit $Obj [with events] [refresh];`) and `rollback` (`rollback $Obj refresh;`):

```mdl
change $Obj (attr = value) refresh;
change $Obj refresh; -- equivalent to today's empty change
```

The describer should emit `refresh` whenever `ChangeObjectAction.RefreshInClient` is true, regardless of whether `Items` is empty or non-empty. The builder should map the modifier into the BSON field.

Proposed fix

  1. Grammar: add optional `REFRESH` token to `changeObjectStatement`.
  2. AST: add `Refresh bool` to `ChangeObjectStmt`.
  3. Visitor: populate the field.
  4. Builder: replace the inferred `len(s.Changes) == 0` with `s.Refresh || len(s.Changes) == 0` (keep the empty-case inference for backwards compatibility).
  5. Formatter: emit `refresh` suffix when `a.RefreshInClient` is true.
  6. Doctype + bug-test for both `change … refresh` and `change … (…) refresh`.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions