Skip to content

Commit

Permalink
refactor: add comment so more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Luthfi Fahlevi committed Aug 21, 2024
1 parent ed7b8ef commit 8c655b2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/queryexpr/sql_expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s SQLExpr) convertToSQL(node ast.Node, stringBuilder *strings.Builder) err
return err
}
case *ast.BuiltinNode, *ast.ConditionalNode:
if err := s.getQueryExprResult(n.String(), stringBuilder); err != nil {
if err := s.getQueryExprResultForSQL(n.String(), stringBuilder); err != nil {
return err
}
default:
Expand All @@ -84,7 +84,7 @@ func (s SQLExpr) convertToSQL(node ast.Node, stringBuilder *strings.Builder) err
func (s SQLExpr) binaryNodeToSQLQuery(n *ast.BinaryNode, stringBuilder *strings.Builder) error {
operator := s.operatorToSQL(n)
if operator == "" { // most likely the node is an operation
if err := s.getQueryExprResult(n.String(), stringBuilder); err != nil {
if err := s.getQueryExprResultForSQL(n.String(), stringBuilder); err != nil {
return err
}
} else {
Expand All @@ -105,8 +105,9 @@ func (s SQLExpr) binaryNodeToSQLQuery(n *ast.BinaryNode, stringBuilder *strings.
return nil
}

func (SQLExpr) getQueryExprResult(fn string, stringBuilder *strings.Builder) error {
result, err := getQueryExprResult(fn)
// getQueryExprResultForSQL using getQueryExprResult to get the result of query expr operation, and make it as SQL syntax
func (SQLExpr) getQueryExprResultForSQL(queryExprOperation string, stringBuilder *strings.Builder) error {
result, err := getQueryExprResult(queryExprOperation)
if err != nil {
return err
}
Expand Down

0 comments on commit 8c655b2

Please sign in to comment.