Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't coalesce closeTime when checking against null #6965

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading