Skip to content

Commit

Permalink
fix: error parsing invalid logical where arrays (#22)
Browse files Browse the repository at this point in the history
When extracting nested actions in logical where arrays we can encounter
an error if the array contains null or undefined. This is because we try
to access a property on those values.

Use optional chaining to ensure that the value is defined before trying
to access a property in logical where arrays.
  • Loading branch information
gkothe authored May 20, 2023
1 parent fff70f4 commit 2e2c3ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/utils/extractNestedActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function extractRelationLogicalWhereActions(

if (Array.isArray(logicalArg)) {
logicalArg.forEach((where, index) => {
const arg = where[relation.name];
const arg = where?.[relation.name];
if (!arg) return;

const operations = [...parentOperations, { logicalOperator, index }];
Expand Down

0 comments on commit 2e2c3ce

Please sign in to comment.