From dd3987cb3ec0e612df6e5ea8a84fde87cc13c2fc Mon Sep 17 00:00:00 2001 From: Pavel Antoshin Date: Wed, 5 Nov 2025 13:59:40 +0100 Subject: [PATCH 1/2] Add example of association update --- .../modeling/domain-model/oql/oql-clauses.md | 2 +- .../domain-model/oql/oql-expression-syntax.md | 2 +- .../domain-model/oql/oql-statements.md | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/content/en/docs/refguide/modeling/domain-model/oql/oql-clauses.md b/content/en/docs/refguide/modeling/domain-model/oql/oql-clauses.md index 1c3aef67b06..dd0f927bb51 100644 --- a/content/en/docs/refguide/modeling/domain-model/oql/oql-clauses.md +++ b/content/en/docs/refguide/modeling/domain-model/oql/oql-clauses.md @@ -199,7 +199,7 @@ It is possible to use more complex expressions in `SELECT`. This is explained in It is also possible to use a subquery. See [Subquery in `SELECT`](/refguide/oql-clauses/#subquery-in-select) for more details. -### Selecting Attributes over Associations +### Selecting Attributes over Associations {#longpath} A unique feature of OQL is the ability to access attributes of associated objects using paths. For example: diff --git a/content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md b/content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md index 26e5a20b732..db53159f81a 100644 --- a/content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md +++ b/content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md @@ -672,7 +672,7 @@ This does not apply to the `=` and `!=` operators. Handling of `NULL` in [other In some databases, using `STRING` type variables in place of numeric, `DATETIME` or `BOOLEAN` values in operators and functions that explicitly require those types, causes the database to perform an implicit conversion. A common example would be the use of a `STRING` representation of a `DATETIME` variable inside a `DATEPART` function. Mendix recommends that you always [cast](#cast) strings to the exact type the operator or functions. -## Functions +## Functions {#functions} These are the currently supported functions: diff --git a/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md b/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md index b3321811cc2..3b588e1fa5f 100644 --- a/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md +++ b/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md @@ -66,15 +66,15 @@ The syntax of `UPDATE` statements is: ```sql UPDATE -SET { = } [ ,...n ] +SET { { | } = } [ ,...n ] WHERE ``` `entity` is the entity whose objects are being updated. -`attribute` is an attribute of the entity that is being updated. Multiple attributes can be updated in the same statement. +`attribute` is an attribute of the entity that is being updated. `association` is an association that is being updated. Multiple attributes and associations can be updated in the same statement. -`expression` is a new value of an attribute. Any [OQL expression](/refguide/oql-expressions/) is allowed. The value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). +`expression` is a new value of an attribute or association. Any [OQL expression](/refguide/oql-expressions/) is allowed. When updating attributes, the value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). In case of associations, association and entity expressions should match the target association type. Values of type LONG can also be used as association values, but they must be valid ids matching the target association type. `condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where). @@ -89,10 +89,18 @@ SET FROM Module.Order WHERE Module.Order_Customer/Module.Customer/ID = Module.Customer/ID ), - Location = Module.Customer_Address/Module.Address/City, - Name = UPPER(Name) + Location = Module.Customer_Address/Module.Address/AddressString, + Name = UPPER(Name), + Module.Customer_Branch = Module.Customer_Address/Module.Address/Module.Address_City/Module.City/Module.Branch_City ``` +In the example above, attributes of entity `Module.Customer` are updated using different capabilities of `OQL UPDATE` functionality: + +- `TotalAmount` attribute is set to a [subqery](/refguide/oql-clauses/#subquery-in-select) with aggregate function +- `Location` is set to a [path](/refguide/oql-clauses/#longpath) over association to attribute +- `Name` is set to a [function](/refguide/oql-expression-syntax/#functions) +- Association `Module.Customer_Branch` is set to a [path](/refguide/oql-clauses/#longpath) over association to an entity + {{% alert color="info" %}} Updating attributes was introduced in Mendix 11.3. From 11e54e903acf7c7a00e7b6d96d13e4d33c9c6afa Mon Sep 17 00:00:00 2001 From: MarkvanMents Date: Thu, 20 Nov 2025 10:11:26 +0100 Subject: [PATCH 2/2] Proofread --- .../modeling/domain-model/oql/oql-statements.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md b/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md index 3b588e1fa5f..b014a089f09 100644 --- a/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md +++ b/content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md @@ -11,7 +11,6 @@ aliases: ## Introduction - OQL statements are translated to SQL statements that are sent to the database. This can be much faster than retrieving the objects in a microflow and then updating or deleting the resulting list. @@ -74,7 +73,7 @@ WHERE `attribute` is an attribute of the entity that is being updated. `association` is an association that is being updated. Multiple attributes and associations can be updated in the same statement. -`expression` is a new value of an attribute or association. Any [OQL expression](/refguide/oql-expressions/) is allowed. When updating attributes, the value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). In case of associations, association and entity expressions should match the target association type. Values of type LONG can also be used as association values, but they must be valid ids matching the target association type. +`expression` is a new value of an attribute or association. Any [OQL expression](/refguide/oql-expressions/) is allowed. When updating attributes, the value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). In the case of associations, association and entity expressions must match the target association type. Values of type LONG can also be used as association values, but they must be valid ids of associations which are of the target association type. `condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where). @@ -96,10 +95,10 @@ SET In the example above, attributes of entity `Module.Customer` are updated using different capabilities of `OQL UPDATE` functionality: -- `TotalAmount` attribute is set to a [subqery](/refguide/oql-clauses/#subquery-in-select) with aggregate function -- `Location` is set to a [path](/refguide/oql-clauses/#longpath) over association to attribute -- `Name` is set to a [function](/refguide/oql-expression-syntax/#functions) -- Association `Module.Customer_Branch` is set to a [path](/refguide/oql-clauses/#longpath) over association to an entity +* `TotalAmount` attribute is set to a [subqery](/refguide/oql-clauses/#subquery-in-select) with aggregate function +* `Location` is set to a [path](/refguide/oql-clauses/#longpath) over association to attribute +* `Name` is set using a [function](/refguide/oql-expression-syntax/#functions) +* Association `Module.Customer_Branch` is set to a [path](/refguide/oql-clauses/#longpath) over association to an entity {{% alert color="info" %}} Updating attributes was introduced in Mendix 11.3.