Skip to content

Commit befeabf

Browse files
authored
Merge pull request #9914 from mendix/MvM-OQLDomainModels
Add domain models and review OQL documentation
2 parents 23a12f2 + bbefcea commit befeabf

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

content/en/docs/refguide/modeling/domain-model/oql/oql-clauses.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Clauses must be presented in the following order, but can be left out if they ar
3838

3939
The `UNION` clause defies the usual order presented above. It will be presented in a [Union Clause](#oql-union) section at the end.
4040

41+
The domain model used in the various examples is shown below:
42+
43+
{{< figure src="/attachments/refguide/modeling/domain-model/oql/oql-clauses-domain-model.png" >}}
44+
4145
## `SELECT` Clause {#select}
4246

4347
The `SELECT` clause specifies which entity attributes or other specified data must be retrieved. The clause returns all the requested values of objects which match the `SELECT` clause.
@@ -111,15 +115,15 @@ The following query returns all attributes of objects of `Sales.Request` that ar
111115
```
112116
SELECT Sales.Request/*
113117
FROM Sales.Customer
114-
JOIN Sales.Customer/Sales.Customer_Request/Sales.Request
118+
JOIN Sales.Customer/Sales.Request_Customer/Sales.Request
115119
```
116120

117121
The following query is equivalent to the previous one, but it uses table aliases
118122

119123
```
120124
SELECT Req/*
121125
FROM Sales.Customer Cust
122-
JOIN Cust/Sales.Customer_Request/Sales.Request Req
126+
JOIN Cust/Sales.Request_Customer/Sales.Request Req
123127
```
124128

125129
### Selecting Distinct Values with `DISTINCT` {#distinct}
@@ -978,7 +982,7 @@ In the example below `Sales.Customer` object for Jim Elk does not have any assoc
978982
```sql
979983
SELECT LastName
980984
FROM Sales.Customer
981-
ORDER BY Sales.Customer/Sales.Customer_Request/Sales.Request/Number
985+
ORDER BY Sales.Customer/Sales.Request_Customer/Sales.Request/Number
982986
```
983987

984988
| LastName |

content/en/docs/refguide/modeling/domain-model/oql/oql-expression-syntax.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Operators and functions in OQL use expressions as inputs to perform mathematical
2525

2626
This document details the use and syntax of expressions in an OQL query.
2727

28+
The domain model used in the various examples is shown below:
29+
30+
{{< figure src="/attachments/refguide/modeling/domain-model/oql/oql-expression-syntax-domain-model.png" >}}
31+
2832
## Data Types
2933

3034
OQL supports a set of data types that differ slightly from [Mendix data types](/refguide/data-types/). The supported data types are:
@@ -544,7 +548,7 @@ Where `expression` is an expression of any datatype.
544548
The `IS` operator can be used to filter out rows with values that are NULL. For example:
545549

546550
```sql
547-
SELECT Revenue, Cost FROM Sales.Finance WHERE Revenue IS NOT NULL
551+
SELECT Revenue, Cost FROM Sales.Finances WHERE Revenue IS NOT NULL
548552
```
549553

550554
| Revenue | Cost |
@@ -803,10 +807,10 @@ COALESCE ( expression [ ,...n ] )
803807

804808
#### Examples {#coalesce-expression-examples}
805809

806-
Assume entity `Sales.Customer` entity now has some `NULL` values:
810+
Assume entity `Sales.CustomerInfo` entity now has some `NULL` values:
807811

808812
```sql
809-
SELECT * FROM Sales.Customer
813+
SELECT * FROM Sales.CustomerInfo
810814
```
811815

812816
| ID | LastName | FirstName | Age | TotalOrderAmount |
@@ -817,7 +821,7 @@ SELECT * FROM Sales.Customer
817821
Selecting a non-null name for a customer, ignoring if it is the first name or last name, can be done with `COALESCE`:
818822

819823
```sql
820-
SELECT COALESCE(LastName, FirstName) AS Name FROM Sales.Customer
824+
SELECT COALESCE(LastName, FirstName) AS Name FROM Sales.CustomerInfo
821825
```
822826

823827
| Name |
@@ -831,7 +835,7 @@ If all arguments have different numeric types, the data type of the expression r
831835
SELECT
832836
COALESCE(Age, TotalOrderAmount) AS AgeOrAmount,
833837
COALESCE(TotalOrderAmount, Age) AS AmountOrAge,
834-
FROM Sales.Customer
838+
FROM Sales.CustomerInfo
835839
```
836840

837841
| AgeOrAmount (type: Decimal) | AmountOrAge (type: Decimal²) |
@@ -1168,18 +1172,18 @@ For example, a space delimited list can be converted to one with commas to be us
11681172
SELECT * FROM Sales.Raw
11691173
```
11701174

1171-
| ID | Import |
1175+
| ID | RawImport |
11721176
|----|-------------------|
11731177
| - | "6 D10 machinery" |
11741178
| - | "1 A15 tools" |
11751179

11761180
The text can be converted with `REPLACE` as follows:
11771181

11781182
```sql
1179-
SELECT REPLACE(Import, ' ', ',') FROM Sales.Raw
1183+
SELECT REPLACE(RawImport, ' ', ',') FROM Sales.Raw
11801184
```
11811185

1182-
| Import |
1186+
| RawImport |
11831187
|-------------------|
11841188
| "6,D10,machinery" |
11851189
| "1,A15,tools" |

content/en/docs/refguide/modeling/domain-model/oql/oql-expressions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ An OQL expression is a query building block that returns a value or a list of va
2020

2121
OQL expressions can be used in `WHERE`, `SELECT`, `GROUP BY`, `UNION`, `HAVING`, and `ON` conditions of `JOIN` clauses. For more information, see [OQL clauses](/refguide/oql-clauses/).
2222

23+
The domain model used in the various examples is shown below:
24+
25+
{{< figure src="/attachments/refguide/modeling/domain-model/oql/oql-expressions-domain-model.png" >}}
26+
2327
## Aggregations{#aggregates}
2428

2529
Aggregations are functions that reduce a list of values from a retrieved column (or columns) into a single value. They can be used in the following ways:
@@ -171,7 +175,7 @@ SELECT MAX(Stock) as StockMax FROM Sales.Product
171175
To return the name(s) of the product(s) with the highest stock level you have to use a subquery. The subquery returns the maximum stock number, which is then compared to each product's stock in the `WHERE` clause:
172176

173177
```sql
174-
SELECT HighestStockProductName FROM Sales.Product
178+
SELECT Name AS HighestStockProductName FROM Sales.Product
175179
WHERE Stock = (SELECT MAX(P.Stock) FROM Sales.Product P)
176180
```
177181

45.6 KB
Loading
58.4 KB
Loading
11 KB
Loading

0 commit comments

Comments
 (0)