Skip to content

Commit

Permalink
Fix using '=' operator against an array (#973)
Browse files Browse the repository at this point in the history
It fixes "[Logs] Web Traffic" dashboard panel:

Before: 
<img width="821" alt="Screenshot 2024-11-12 at 12 14 35"
src="https://github.com/user-attachments/assets/d594da02-4615-49f2-b489-6b87af7b6724">


After:
<img width="829" alt="Screenshot 2024-11-12 at 12 15 30"
src="https://github.com/user-attachments/assets/899e04ea-9076-4da6-869c-b1db67a96e7f">
  • Loading branch information
nablaone authored Nov 12, 2024
1 parent 32af378 commit 674a501
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions quesma/quesma/schema_array_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,19 @@ func NewArrayTypeVisitor(resolver arrayTypeResolver) model.ExprVisitor {
dbType := resolver.dbColumnType(column.ColumnName)
if strings.HasPrefix(dbType, "Array") {
op := strings.ToUpper(e.Op)
op = strings.TrimSpace(op)
switch {
case (op == "ILIKE" || op == "LIKE") && dbType == "Array(String)":

variableName := "x"
lambda := model.NewLambdaExpr([]string{variableName}, model.NewInfixExpr(model.NewLiteral(variableName), op, e.Right.Accept(b).(model.Expr)))
return model.NewFunction("arrayExists", lambda, e.Left)

case e.Op == "=":
case op == "=":
return model.NewFunction("has", e.Left, e.Right.Accept(b).(model.Expr))

default:
logger.Error().Msgf("Unhandled array infix operation %s, column %v (%v)", e.Op, column.ColumnName, dbType)
logger.Error().Msgf("Unhandled array infix operation '%s', column '%v' ('%v')", e.Op, column.ColumnName, dbType)
}
}
}
Expand Down

0 comments on commit 674a501

Please sign in to comment.