Skip to content

Commit

Permalink
PLIN-4268 add since flag (#103)
Browse files Browse the repository at this point in the history
* PLIN-4268: adds support for more comparison operators than =

* remove debugging
  • Loading branch information
acofer authored Mar 23, 2023
1 parent 9c5183d commit a5323bd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ SQL translation in WHERE clause grouping:
t0.field_B = "bar"
*/
type FieldFilter struct {
FieldName string
FilterValue interface{}
FieldName string
FilterValue interface{}
FilterOperator string
}

// Apply applies the filter
Expand All @@ -247,7 +248,19 @@ func (ff FieldFilter) Apply(table *qp.Table, metadata *TableMetadata) squirrel.S
}
fieldMetadata := metadata.GetField(ff.FieldName)
columnName := fieldMetadata.GetColumnName()
return squirrel.Eq{fmt.Sprintf(qp.AliasedField, table.Alias, columnName): ff.FilterValue}
expr := fmt.Sprintf(qp.AliasedField, table.Alias, columnName)
switch ff.FilterOperator {
case "<":
return squirrel.Lt{expr: ff.FilterValue}
case "<=":
return squirrel.LtOrEq{expr: ff.FilterValue}
case ">":
return squirrel.Gt{expr: ff.FilterValue}
case ">=":
return squirrel.GtOrEq{expr: ff.FilterValue}
default:
return squirrel.Eq{expr: ff.FilterValue}
}
}

// OrFilterGroup applies a group of filters using ors
Expand Down

0 comments on commit a5323bd

Please sign in to comment.