Open lgiannini1 opened 2 months ago
This is due to how TypeORM interprets and executes conditional logic in its find
options: it is an open issue, although it hasn't yet been addressed as a bug in the package. In particular, the manifestation of this issue in ECMPS stems from applying an OR
condition in the IsValidCodes
validation pipe of the ErrorSuppressionPayloadDTO
's locations
attribute.
While it is possible to specify an OR
condition when using TypeORM's find
method, it appears that TypeORM first evaluates each side of the clause using an INNER JOIN
when specifying nested relations.
There are at least two potential workarounds:
SelectQueryBuilder
instead of the repository's find
methodBoth workarounds require updating the IsValidCodes
pipe. It is my opinion that option 2 is a better choice: the required changes are simpler and the queries can take advantage of parallelism to improve performance.
EDIT
After some reconsideration, I've decided to move forward with option 1 from the workarounds noted above. The IsValidCodes
pipe compares the result count against the expected number of codes rather than just the presence of results, so there is a possibility that executing multiple queries could return more rows than a single joined query (although this would not be the case in any uses of the pipe in the current codebase).
Since this is an edge case, I think creating a separate, specialized pipe/validator is the safer solution, and it will prevent needlessly cluttering the IsValidCodes
logic.
Error Suppression was able to be created following above parameters without running into above error.
Verified in test environment - error suppression was successfully added without error message.
When trying to save a new error suppression record, the following error is generated if a location is selected from the dropdown.