Skip to content

Commit

Permalink
Don't coalesce closeTime when checking against null
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarzee committed Dec 13, 2024
1 parent f2d52ed commit 00e8459
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions common/persistence/visibility/store/sql/query_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,23 @@ func (c *QueryConverter) convertIsExpr(exprRef *sqlparser.Expr) error {
if !ok {
return query.NewConverterError("`%s` is not an 'IS' expression", sqlparser.String(*exprRef))
}
_, err := c.convertColName(&expr.Expr)
if err != nil {
return err
}

switch expr.Operator {
case sqlparser.IsNullStr, sqlparser.IsNotNullStr:
// no-op

// skip closeTime to avoid coalesce
if subExpr, ok := (expr.Expr).(*sqlparser.ColName); ok {
saAlias := strings.ReplaceAll(sqlparser.String(subExpr), "`", "")
if saAlias == searchattribute.CloseTime {
expr.Expr = closeTimeSaColName
return nil
}
}

_, err := c.convertColName(&expr.Expr)
if err != nil {
return err
}
default:
return query.NewConverterError(
"%s: 'IS' operator can only be used with 'NULL' or 'NOT NULL'",
Expand Down

0 comments on commit 00e8459

Please sign in to comment.