Skip to content

Commit

Permalink
Merge pull request #241 from jetstreamapp/breaking/v5
Browse files Browse the repository at this point in the history
Breaking/v5
  • Loading branch information
paustint authored Jan 13, 2024
2 parents 2298c55 + 248e7a2 commit 9d0b718
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# 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
Expand Down
16 changes: 14 additions & 2 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,7 +157,7 @@ export interface Subquery extends QueryBase {
sObjectPrefix?: string[];
}

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

export interface WhereClauseWithoutOperator {
left: ConditionWithValueQuery;
Expand All @@ -165,6 +168,15 @@ export interface WhereClauseWithRightCondition extends WhereClauseWithoutOperato
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
5 changes: 3 additions & 2 deletions 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,8 +733,8 @@ class SOQLVisitor extends BaseSoqlVisitor {
}

expressionPartWithNegation(ctx: any) {
const output: Partial<WhereClauseWithRightCondition> = {
left: ctx.L_PAREN ? { openParen: ctx.L_PAREN.length } : (null as any), // FIXME: type does not allow null, but changing is a breaking change
const output: Partial<WhereClauseWithoutNegationOperator> = {
left: ctx.L_PAREN ? { openParen: ctx.L_PAREN.length } : null,
operator: 'NOT',
right: {
left: {} as ValueCondition,
Expand Down

0 comments on commit 9d0b718

Please sign in to comment.