Skip to content

Commit

Permalink
fix: query operator desc to value (openGemini#166)
Browse files Browse the repository at this point in the history
Signed-off-by: Young Xu <xuthus5@gmail.com>
  • Loading branch information
xuthus5 authored Aug 18, 2024
1 parent 2a8df7f commit e689ed3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
18 changes: 1 addition & 17 deletions opengemini/query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,7 @@ func (q *QueryBuilder) buildExpression(expr Expression) string {
func (q *QueryBuilder) buildCondition(cond Condition) string {
switch c := cond.(type) {
case *ComparisonCondition:
// Map ComparisonOperator to SQL symbols
var operator string
switch c.Operator {
case Equals:
operator = "="
case NotEquals:
operator = "<>"
case GreaterThan:
operator = ">"
case LessThan:
operator = "<"
case GreaterThanOrEquals:
operator = ">="
case LessThanOrEquals:
operator = "<="
}
return fmt.Sprintf(`"%s" %s '%v'`, c.Column, operator, c.Value)
return fmt.Sprintf(`"%s" %s '%v'`, c.Column, c.Operator, c.Value)
case *CompositeCondition:
var parts []string
for _, condition := range c.Conditions {
Expand Down
14 changes: 8 additions & 6 deletions opengemini/query_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package opengemini
type ComparisonOperator string

const (
Equals ComparisonOperator = "EQUALS"
NotEquals ComparisonOperator = "NOT_EQUALS"
GreaterThan ComparisonOperator = "GREATER_THAN"
LessThan ComparisonOperator = "LESS_THAN"
GreaterThanOrEquals ComparisonOperator = "GREATER_THAN_OR_EQUALS"
LessThanOrEquals ComparisonOperator = "LESS_THAN_OR_EQUALS"
Equals ComparisonOperator = "="
NotEquals ComparisonOperator = "<>"
GreaterThan ComparisonOperator = ">"
LessThan ComparisonOperator = "<"
GreaterThanOrEquals ComparisonOperator = ">="
LessThanOrEquals ComparisonOperator = "<="
Match ComparisonOperator = "=~"
NotMatch ComparisonOperator = "!~"
)

type LogicalOperator string
Expand Down

0 comments on commit e689ed3

Please sign in to comment.