forked from ArjenLammers/oqlmodule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up README.md and unify .gitignore with other modules
- Loading branch information
Showing
45 changed files
with
71 additions
and
21,983 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
/deployment | ||
/GPUCache | ||
#Editors | ||
/.idea/ | ||
/.vscode/ | ||
/.settings/ | ||
*.iml | ||
|
||
#Build | ||
/*.launch | ||
/deployment/ | ||
/packages/ | ||
/releases/ | ||
/theme-cache/ | ||
/.mendix-cache/ | ||
|
||
#Mendix | ||
/userlib/ | ||
/*.mpk | ||
!/CSVAsTable.mpk | ||
/.classpath | ||
/.project | ||
/oqlmodule.mpr.bak | ||
/oqlmodule.mpr.lock | ||
/modeler-merge-marker | ||
/*.lock | ||
/*.bak | ||
/project-settings.user.json | ||
|
||
#Source | ||
/javasource/*/proxies/ | ||
/javasource/system/ | ||
/**/node_modules/ | ||
!/javascriptsource/**/node_modules/ | ||
/nativemobile/builds/ | ||
|
||
#Gradle | ||
./gradle/ | ||
/build/ | ||
/upgraded/ | ||
|
||
#Other | ||
/releases/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,67 @@ | ||
# Description | ||
This module allows you to execute OQL queries from a microflow.It allows setting named parameters which will be properly escaped. | ||
This module allows you to execute OQL queries from a microflow. It allows setting named parameters which will be properly escaped. | ||
|
||
# Typical usage scenario | ||
Query data from the Mendix database and the result will be mapped to a Mendix entity. | ||
The example below is part of the Example module within the project, located on the GitHub repository. | ||
|
||
Considering the following domain model: | ||
As an example, one can execute a query obtaining all objects of `ExamplePerson` as a table. The rows within this table can be converted to non-persistent entities for further usage. A `ExamplePersonResult` non-persistent entity is modeled. | ||
|
||
One can execute a query obtaining all objects of ExamplePerson as a table. The rows within this table can be converted to non persistent entities for further usage. Therefore a ExamplePersonResult non persistent entity is modeled. | ||
|
||
Parameters can be used using their corresponding actions (for each data type there's one activity defined: | ||
|
||
|
||
|
||
All parameters should be added before executing an OQL query. | ||
|
||
|
||
Parameters can be used using their corresponding actions. For each data type there's one activity defined. All parameters should be added before executing an OQL query. | ||
|
||
Adding an parameter requires: | ||
* The name of the parameter, without a $ (e.g. Gender). | ||
* The value. | ||
|
||
The name of the parameter, without a $ (e.g. Gender). | ||
The value. | ||
Executing an OQL query requires: | ||
|
||
The OQL statement. | ||
A resulting entity (e.g. OQLExample.ExamplePersonResult). | ||
Amount. | ||
Offset. | ||
* The OQL statement | ||
* A resulting entity (e.g. OQLExample.ExamplePersonResult) | ||
* Amount | ||
* Offset | ||
|
||
|
||
After executing an OQL query, all previously set parameters are cleared. | ||
|
||
The example query used to obtain the ExamplePersonResults are is: | ||
|
||
``SELECT P.id ExamplePersonResult_ExamplePerson, P.Name Name, P.Number Number, P.DateOfBirth DateOfBirth, P.Age Age, P.LongAge LongAge, P.HeightInFloat HeightInFloat, P.HeightInDecimal HeightInDecimal, P.Active Active, P.Gender Gender FROM OQLExample.ExamplePerson P WHERE P.Active = $Active AND P.Age = $Age AND P.DateOfBirth = $DateOfBirth AND P.Gender = $Gender AND P.HeightInDecimal = $HeightInDecimal AND P.HeightInFloat = $HeightInFloat AND P.LongAge = $LongAge AND P.Name = $Name AND P.Number = $Number AND P/OQL.MarriedTo/OQL.ExamplePerson/ID = $MarriedTo`` | ||
|
||
In the example above, the resulting columns Name, Number, DateOfBirth, Age, etc. are mapped to their corresponding attributes in ExamplePersonResult. The column ExamplePersonResult_ExamplePerson is mapped to the association (so one can retrieve the original persistent entity if needed). | ||
|
||
# Features and limitations | ||
|
||
Named parameters (like Data Set functionality) to avoid injection. | ||
Automatic mapping of result table to a list of objects (of a supplied entity). | ||
Mapping of an ID column to an assocation. | ||
### Example query | ||
|
||
The example query used to obtain the ExamplePersonResults is: | ||
|
||
```sql | ||
SELECT | ||
P.id ExamplePersonResult_ExamplePerson, | ||
P.Name Name, | ||
P.Number Number, | ||
P.DateOfBirth DateOfBirth, | ||
P.Age Age, | ||
P.LongAge LongAge, | ||
P.HeightInFloat HeightInFloat, | ||
P.HeightInDecimal HeightInDecimal, | ||
P.Active Active, | ||
P.Gender Gender | ||
FROM OQLExample.ExamplePerson P | ||
WHERE | ||
P.Active = $Active AND | ||
P.Age = $Age AND P.DateOfBirth = $DateOfBirth AND | ||
P.Gender = $Gender AND | ||
P.HeightInDecimal = $HeightInDecimal AND | ||
P.HeightInFloat = $HeightInFloat AND P.LongAge = $LongAge AND | ||
P.Name = $Name AND P.Number = $Number AND | ||
P/OQL.MarriedTo/OQL.ExamplePerson/ID = $MarriedTo | ||
``` | ||
|
||
In the example above, the resulting columns `Name`, `Number`, `DateOfBirth`, `Age`, etc. are mapped to their corresponding attributes in `ExamplePersonResult`. The column `ExamplePersonResult_ExamplePerson` is mapped to the association, so the original persistent entity can be retrieved if needed. | ||
|
||
# Features | ||
|
||
* Named parameters (like Data Set functionality) to avoid injection. | ||
* Automatic mapping of result table to a list of objects (of a supplied entity). | ||
* Mapping of an ID column to an assocation. | ||
|
||
# Dependencies | ||
Mendix 6.9 or newer | ||
Mendix 9.18.4 or newer | ||
|
||
# Installation | ||
Download and import into your project. | ||
Download from marketplace and import into your project. | ||
|
||
# Known bugs | ||
A mapped association should be mentioned without its module prefix in an OQL query (e.g. ExamplePersonResult_ExamplePerson instead of OQLExample.ExamplePersonResult_ExamplePerson). | ||
A mapped association should be mentioned without its module prefix in an OQL query (e.g. `ExamplePersonResult_ExamplePerson` instead of `OQLExample.ExamplePersonResult_ExamplePerson`). |
Oops, something went wrong.