Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/src/stores/webdaql/WebdaQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ expression
identifier LIKE stringLiteral #likeExpression
| identifier IN setExpression #inExpression
| identifier CONTAINS stringLiteral #containsExpression
// IS NULL / IS NOT NULL
| identifier IS NULL #isNullExpression
| identifier IS NOT NULL #isNotNullExpression
// Comparison operations
| identifier (EQUAL | NOT_EQUAL | GREATER_OR_EQUAL | LESS_OR_EQUAL | LESS | GREATER) values #binaryComparisonExpression
// Logic operations
Expand Down
22 changes: 21 additions & 1 deletion packages/core/src/stores/webdaql/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@
return new ComparisonExpression("CONTAINS", left.text, value);
}

/**
* IS NULL expression
*/
visitIsNullExpression(ctx: any) {
const left = ctx.getChild(0);
return new ComparisonExpression("IS NULL", left.text, null);
}

Check warning on line 242 in packages/core/src/stores/webdaql/query.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/stores/webdaql/query.ts#L240-L242

Added lines #L240 - L242 were not covered by tests

/**
* IS NOT NULL expression
*/
visitIsNotNullExpression(ctx: any) {
const left = ctx.getChild(0);
return new ComparisonExpression("IS NOT NULL", left.text, null);
}

Check warning on line 250 in packages/core/src/stores/webdaql/query.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/stores/webdaql/query.ts#L248-L250

Added lines #L248 - L250 were not covered by tests

/**
* Get the OrExpression, regrouping all the parameters
*
Expand Down Expand Up @@ -319,7 +335,7 @@
abstract toString(depth?: number): string;
}

export type ComparisonOperator = "=" | "<=" | ">=" | "<" | ">" | "!=" | "LIKE" | "IN" | "CONTAINS";
export type ComparisonOperator = "=" | "<=" | ">=" | "<" | ">" | "!=" | "LIKE" | "IN" | "CONTAINS" | "IS NULL" | "IS NOT NULL";
/**
* Comparison expression
*/
Expand Down Expand Up @@ -430,6 +446,10 @@
return left.includes(this.value);
}
return false;
case "IS NOT NULL":
return left !== null && left !== undefined;

Check warning on line 450 in packages/core/src/stores/webdaql/query.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/stores/webdaql/query.ts#L450

Added line #L450 was not covered by tests
case "IS NULL":
return left === null || left === undefined;

Check warning on line 452 in packages/core/src/stores/webdaql/query.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/stores/webdaql/query.ts#L452

Added line #L452 was not covered by tests
}
}

Expand Down
Loading