Skip to content

Commit

Permalink
Wrap Queries Containing TYPEOF
Browse files Browse the repository at this point in the history
  • Loading branch information
cwarden committed Jan 14, 2025
1 parent 8e2a540 commit 68ec2e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions formatter/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func (v *ChainVisitor) VisitSelectEntry(ctx *parser.SelectEntryContext) interfac
// estimate complexity; probably close enough
return 5
}
if ctx.TypeOf() != nil {
return 3
}
return 1
}

Expand Down
26 changes: 26 additions & 0 deletions formatter/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,32 @@ b);`,
.save();
}`,
},
{
`return Database.getQueryLocator(
[
SELECT
TYPEOF What
WHEN Account_Profile__c THEN Account__c, Marketing_Team__c
END
FROM Event
WHERE WhatId IN :this.oldAccountProfileIds
]
);`,
`return Database.getQueryLocator([
SELECT
TYPEOF What
WHEN
Account_Profile__c
THEN
Account__c,
Marketing_Team__c
END
FROM
Event
WHERE
WhatId IN :this.oldAccountProfileIds
]);`,
},
}
dmp := diffmatchpatch.New()
for i, tt := range tests {
Expand Down

0 comments on commit 68ec2e3

Please sign in to comment.