Skip to content

Commit 9d56eea

Browse files
hjothamendixclaude
andcommitted
test: add bug-test reproducer for indirect-sort entity reference
Adds an MDL script under mdl-examples/bug-tests/ exercising a retrieve sorted by an attribute on a related entity via a one-hop association. After exec, `mx check` reports 0 errors and the describe output preserves the qualified `Module.Entity.Attribute` form, confirming the IndirectEntityRef step survives roundtrip. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2b29d32 commit 9d56eea

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- ============================================================================
2+
-- Bug #367: Retrieve sort items lost indirect entity references
3+
-- ============================================================================
4+
--
5+
-- Symptom (before fix):
6+
-- A retrieve source can sort by an attribute whose owning entity differs
7+
-- from the retrieved entity, as long as Studio Pro has an association
8+
-- path for that attribute. Example: retrieve DeploymentTarget sorted by
9+
-- ApplicationView.CreatedAt through DeploymentTarget_ApplicationView.
10+
-- The SDK shape only stored the final attribute reference, so parser/
11+
-- writer roundtrip dropped the `DomainModels$IndirectEntityRef` steps,
12+
-- and the MDL builder rejected qualified sort attributes when the
13+
-- attribute entity differed from the retrieve entity.
14+
--
15+
-- After fix:
16+
-- - Parser/writer now preserve `DomainModels$IndirectEntityRef` steps.
17+
-- - The MDL builder infers a one-hop association sort reference and
18+
-- emits the IndirectEntityRef path. Unrelated qualified attributes
19+
-- are still rejected.
20+
--
21+
-- Usage:
22+
-- mxcli exec mdl-examples/bug-tests/367-retrieve-sort-indirect-entity-ref.mdl -p app.mpr
23+
-- mxcli -p app.mpr -c "describe microflow BugTest367.MF_FetchSorted"
24+
-- `mx check` against the resulting MPR must report 0 errors and the
25+
-- describe output must keep the qualified `Module.Entity.Attribute`
26+
-- sort form.
27+
-- ============================================================================
28+
29+
create module BugTest367;
30+
31+
create entity BugTest367.ApplicationView (
32+
CreatedAt : datetime
33+
);
34+
/
35+
36+
create entity BugTest367.DeploymentTarget (
37+
Name : string(100)
38+
);
39+
/
40+
41+
create association BugTest367.DeploymentTarget_ApplicationView
42+
from BugTest367.DeploymentTarget
43+
to BugTest367.ApplicationView;
44+
/
45+
46+
-- Sort uses an attribute on a related entity. The builder must emit the
47+
-- IndirectEntityRef step through DeploymentTarget_ApplicationView so the
48+
-- BSON parses cleanly in Studio Pro.
49+
create microflow BugTest367.MF_FetchSorted ()
50+
returns list of BugTest367.DeploymentTarget as $Targets
51+
begin
52+
retrieve $Targets from BugTest367.DeploymentTarget
53+
sort by BugTest367.ApplicationView.CreatedAt desc, Name asc;
54+
end;
55+
/

0 commit comments

Comments
 (0)