You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: system attributes as pseudo-types (AutoOwner, AutoChangedBy, etc.)
Replace STORE OWNER/CHANGED BY/CREATED DATE/CHANGED DATE syntax on
CREATE ENTITY with pseudo-typed attributes in the attribute list:
Owner: AutoOwner,
ChangedBy: AutoChangedBy,
CreatedDate: AutoCreatedDate,
ChangedDate: AutoChangedDate
These follow the AutoNumber pattern — the type name communicates
"system-generated, read-only". DESCRIBE now outputs them as regular
attributes. ALTER ENTITY SET/DROP STORE remains for toggling on
existing entities.
Also fixes Mendix 11.9.0 BSON field rename (HasOwner → HasOwnerAttr)
and version-aware writer output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mendix supports four built-in auditing properties on persistent entities. These are stored at the entity level (not as regular attributes) and the system fills them automatically:
201
+
Mendix supports four built-in auditing properties on persistent entities. Declare them as regular attributes using pseudo-types (like `AutoNumber`):
202
202
203
-
| Clause | Effect |
204
-
|--------|--------|
205
-
|`STORE OWNER`| Adds `System.owner` association to System.User; set on insert |
206
-
|`STORE CHANGED BY`| Adds `System.changedBy` association to System.User; updated on every commit |
207
-
|`STORE CREATED DATE`| Adds `CreatedDate` (DateTime); set on insert |
208
-
|`STORE CHANGED DATE`| Adds `ChangedDate` (DateTime); updated on every commit |
209
-
210
-
**Position**: STORE clauses go AFTER the closing parenthesis of attributes, before the semicolon. They can appear in any order.
203
+
| Pseudo-Type | System Attribute | Set When |
204
+
|-------------|-----------------|----------|
205
+
|`AutoOwner`|`System.owner` (→ System.User) | Object created |
206
+
|`AutoChangedBy`|`System.changedBy` (→ System.User) | Every commit |
207
+
|`AutoCreatedDate`|`CreatedDate` (DateTime) | Object created |
208
+
|`AutoChangedDate`|`ChangedDate` (DateTime) | Every commit |
211
209
212
210
```sql
213
211
/**
@@ -216,12 +214,12 @@ Mendix supports four built-in auditing properties on persistent entities. These
216
214
CREATE PERSISTENT ENTITY Sales.Order (
217
215
OrderNumber: AutoNumber,
218
216
TotalAmount: DecimalNOT NULL,
219
-
Status: Enumeration(Sales.OrderStatus) NOT NULL
220
-
)
221
-
STORE OWNER
222
-
STORE CHANGED BY
223
-
STORE CREATED DATE
224
-
STORE CHANGED DATE;
217
+
Status: Enumeration(Sales.OrderStatus) NOT NULL,
218
+
Owner: AutoOwner,
219
+
ChangedBy: AutoChangedBy,
220
+
CreatedDate: AutoCreatedDate,
221
+
ChangedDate: AutoChangedDate
222
+
);
225
223
```
226
224
227
225
To enable/disable on existing entities, use ALTER ENTITY:
@@ -234,8 +232,8 @@ ALTER ENTITY Sales.Order DROP STORE CHANGED BY;
234
232
235
233
**When to use auditing:**
236
234
- Compliance/regulated domains (finance, healthcare) — use all four
237
-
- User-generated content — use STORE OWNER for ownership rules
238
-
- "Recently modified" lists — use STORE CHANGED DATE
235
+
- User-generated content — use AutoOwner for ownership-based access rules
236
+
- "Recently modified" lists — use AutoChangedDate
239
237
- Avoid on high-volume system tables (every write touches the audit columns)
Persistent entities can track who created/modified objects and when, using built-in system attributes. Add these clauses after the closing parenthesis:
100
+
Persistent entities can track who created/modified objects and when. Declare them as regular attributes using pseudo-types (like `AutoNumber`):
101
101
102
102
```sql
103
103
CREATE PERSISTENT ENTITY Sales.Order (
104
104
OrderNumber: AutoNumber,
105
-
TotalAmount: Decimal
106
-
)
107
-
STORE OWNER
108
-
STORE CHANGED BY
109
-
STORE CREATED DATE
110
-
STORE CHANGED DATE;
105
+
TotalAmount: Decimal,
106
+
Owner: AutoOwner,
107
+
ChangedBy: AutoChangedBy,
108
+
CreatedDate: AutoCreatedDate,
109
+
ChangedDate: AutoChangedDate
110
+
);
111
111
```
112
112
113
-
|Clause| System Attribute| Type| Set When |
114
-
|--------|-----------------|------|----------|
115
-
|`STORE OWNER`|`System.owner`| Association → System.User | Object created |
116
-
|`STORE CHANGED BY`|`System.changedBy`| Association → System.User | Every commit |
117
-
|`STORE CREATED DATE`|`CreatedDate`|DateTime | Object created |
118
-
|`STORE CHANGED DATE`|`ChangedDate`|DateTime | Every commit |
113
+
|Pseudo-Type| System Attribute | Set When |
114
+
|-------------|-----------------|----------|
115
+
|`AutoOwner`|`System.owner`(→ System.User)| Object created |
116
+
|`AutoChangedBy`|`System.changedBy`(→ System.User)| Every commit |
117
+
|`AutoCreatedDate`|`CreatedDate`(DateTime)| Object created |
118
+
|`AutoChangedDate`|`ChangedDate`(DateTime)| Every commit |
| Create with extends |`CREATE PERSISTENT ENTITY Module.Name EXTENDS Parent.Entity (attrs);`| EXTENDS before `(`|
39
-
| Create with auditing |`CREATE PERSISTENT ENTITY Module.Name (attrs) STORE OWNER STORE CHANGED BY STORE CREATED DATE STORE CHANGED DATE;`|System attributes added automatically|
39
+
| Create with auditing |`CREATE PERSISTENT ENTITY Module.Name (attrs, Owner: AutoOwner, ChangedBy: AutoChangedBy, CreatedDate: AutoCreatedDate, ChangedDate: AutoChangedDate);`|Pseudo-types like AutoNumber|
0 commit comments