Skip to content
Merged
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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 5.0.0

Jan 13, 2024

💥 Breaking Changes
Fixed a bug where with typescript types to properly represent that `WhereClause` can have a null value for `left` in the case of a negation operator.
This was always the case, but prior to enabling strict typescript types, this went under the radar.

For Typescript consumers that have strict null checks enabled, they may need to make code changes depending on usage.

## 4.10.1

Jan 13, 2024

Revert accidental breaking change to types. `WhereClause` left can have `null` in the negation case, but the types did not represent this.
Updating types to match reality is a breaking change for consumers, so worked around issue and will publish version 5 with breaking change.

## 4.10.0

Jan 13, 2024
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "soql-parser-js",
"version": "4.10.0",
"version": "4.10.1",
"description": "Salesforce.com SOQL parser and composer",
"main": "dist/index.js",
"module": "dist_esm/index.js",
Expand Down
18 changes: 15 additions & 3 deletions src/api/api-models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export type LogicalOperator = 'AND' | 'OR' | 'NOT';
export type LogicalOperatorAnd = 'AND';
export type LogicalOperatorOr = 'OR';
export type LogicalOperatorNot = 'NOT';
export type LogicalOperator = LogicalOperatorAnd | LogicalOperatorOr | LogicalOperatorNot;
export type Operator = '=' | '!=' | '<=' | '>=' | '>' | '<' | 'LIKE' | 'IN' | 'NOT IN' | 'INCLUDES' | 'EXCLUDES';
export type FieldTypeOfConditionType = 'WHEN' | 'ELSE';
export type GroupSelector = 'ABOVE' | 'AT' | 'BELOW' | 'ABOVE_OR_BELOW';
Expand Down Expand Up @@ -154,17 +157,26 @@ export interface Subquery extends QueryBase {
sObjectPrefix?: string[];
}

export type WhereClause = WhereClauseWithoutOperator | WhereClauseWithRightCondition;
export type WhereClause = WhereClauseWithoutOperator | WhereClauseWithoutNegationOperator | WhereClauseWithRightCondition;

export interface WhereClauseWithoutOperator {
left: ConditionWithValueQuery | null;
left: ConditionWithValueQuery;
}

export interface WhereClauseWithRightCondition extends WhereClauseWithoutOperator {
operator: LogicalOperator;
right: WhereClause;
}

/**
* This is a special case where the left side of the where clause can potentially be null if there is a negation without parentheses
*/
export interface WhereClauseWithoutNegationOperator {
left: NegationCondition | null;
operator: LogicalOperatorNot;
right: WhereClause;
}

export type Condition =
| ValueCondition
| ValueWithDateLiteralCondition
Expand Down
3 changes: 2 additions & 1 deletion src/parser/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
ValueWithDateNLiteralCondition,
WhereClause,
WhereClauseWithRightCondition,
WhereClauseWithoutNegationOperator,
WithDataCategoryCondition,
} from '../api/api-models';
import {
Expand Down Expand Up @@ -732,7 +733,7 @@ class SOQLVisitor extends BaseSoqlVisitor {
}

expressionPartWithNegation(ctx: any) {
const output: Partial<WhereClauseWithRightCondition> = {
const output: Partial<WhereClauseWithoutNegationOperator> = {
left: ctx.L_PAREN ? { openParen: ctx.L_PAREN.length } : null,
operator: 'NOT',
right: {
Expand Down