Skip to content

Commit 9d0b718

Browse files
authored
Merge pull request #241 from jetstreamapp/breaking/v5
Breaking/v5
2 parents 2298c55 + 248e7a2 commit 9d0b718

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 5.0.0
4+
5+
Jan 13, 2024
6+
7+
💥 Breaking Changes
8+
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.
9+
This was always the case, but prior to enabling strict typescript types, this went under the radar.
10+
11+
For Typescript consumers that have strict null checks enabled, they may need to make code changes depending on usage.
12+
313
## 4.10.1
414

515
Jan 13, 2024

src/api/api-models.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export type LogicalOperator = 'AND' | 'OR' | 'NOT';
1+
export type LogicalOperatorAnd = 'AND';
2+
export type LogicalOperatorOr = 'OR';
3+
export type LogicalOperatorNot = 'NOT';
4+
export type LogicalOperator = LogicalOperatorAnd | LogicalOperatorOr | LogicalOperatorNot;
25
export type Operator = '=' | '!=' | '<=' | '>=' | '>' | '<' | 'LIKE' | 'IN' | 'NOT IN' | 'INCLUDES' | 'EXCLUDES';
36
export type FieldTypeOfConditionType = 'WHEN' | 'ELSE';
47
export type GroupSelector = 'ABOVE' | 'AT' | 'BELOW' | 'ABOVE_OR_BELOW';
@@ -154,7 +157,7 @@ export interface Subquery extends QueryBase {
154157
sObjectPrefix?: string[];
155158
}
156159

157-
export type WhereClause = WhereClauseWithoutOperator | WhereClauseWithRightCondition;
160+
export type WhereClause = WhereClauseWithoutOperator | WhereClauseWithoutNegationOperator | WhereClauseWithRightCondition;
158161

159162
export interface WhereClauseWithoutOperator {
160163
left: ConditionWithValueQuery;
@@ -165,6 +168,15 @@ export interface WhereClauseWithRightCondition extends WhereClauseWithoutOperato
165168
right: WhereClause;
166169
}
167170

171+
/**
172+
* This is a special case where the left side of the where clause can potentially be null if there is a negation without parentheses
173+
*/
174+
export interface WhereClauseWithoutNegationOperator {
175+
left: NegationCondition | null;
176+
operator: LogicalOperatorNot;
177+
right: WhereClause;
178+
}
179+
168180
export type Condition =
169181
| ValueCondition
170182
| ValueWithDateLiteralCondition

src/parser/visitor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
ValueWithDateNLiteralCondition,
3131
WhereClause,
3232
WhereClauseWithRightCondition,
33+
WhereClauseWithoutNegationOperator,
3334
WithDataCategoryCondition,
3435
} from '../api/api-models';
3536
import {
@@ -732,8 +733,8 @@ class SOQLVisitor extends BaseSoqlVisitor {
732733
}
733734

734735
expressionPartWithNegation(ctx: any) {
735-
const output: Partial<WhereClauseWithRightCondition> = {
736-
left: ctx.L_PAREN ? { openParen: ctx.L_PAREN.length } : (null as any), // FIXME: type does not allow null, but changing is a breaking change
736+
const output: Partial<WhereClauseWithoutNegationOperator> = {
737+
left: ctx.L_PAREN ? { openParen: ctx.L_PAREN.length } : null,
737738
operator: 'NOT',
738739
right: {
739740
left: {} as ValueCondition,

0 commit comments

Comments
 (0)