-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UIPQB-85] Use non-id columns for queries
- Loading branch information
1 parent
4330ef4
commit a80f3da
Showing
3 changed files
with
33 additions
and
3 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
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
24 changes: 24 additions & 0 deletions
24
src/QueryBuilder/QueryBuilder/helpers/upgradeInitialValues.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Upgrades initial values to indirectly reference id columns (e.g. vendor_code instead of vendor_id). | ||
* FQM used to previously require vendor_id, but this was changed in MODFQMMGR-151 to allow for better expression | ||
* and to allow for more flexibility in the future. | ||
*/ | ||
export default function upgradeInitialValues(initialValues, entityType) { | ||
const idColumnMapping = {}; | ||
|
||
entityType?.columns.forEach((column) => { | ||
if (column.idColumnName) { | ||
idColumnMapping[column.idColumnName] = column.name; | ||
} | ||
}); | ||
|
||
const upgradedInitialValues = {}; | ||
|
||
Object.keys(initialValues).forEach((key) => { | ||
const newKey = idColumnMapping[key] || key; | ||
|
||
upgradedInitialValues[newKey] = initialValues[key]; | ||
}); | ||
|
||
return upgradedInitialValues; | ||
} |