@@ -27,6 +27,8 @@ const (
2727 OpBetween = "between"
2828 OpIn = "in"
2929 OpNotIn = "notin"
30+ OpNull = "null"
31+ OpNotNull = "notnull"
3032)
3133
3234type FilterData struct {
@@ -75,7 +77,7 @@ func checkValueCount(operator string, nValues int) bool {
7577}
7678
7779// Convert a single filter to where clauses
78- func (t * FilterData ) ToWhere (fieldName string , attributes database.AttrMap ) (string , []interface {} , error ) {
80+ func (t * FilterData ) ToWhere (fieldName string , attributes database.AttrMap ) (string , []any , error ) {
7981 var err error
8082 transformedValues , transformedOperator := transformFilterParams (fieldName , t .Values , t .Operator )
8183 var values = make ([]interface {}, len (transformedValues ))
@@ -113,9 +115,13 @@ func (t *FilterData) ToWhere(fieldName string, attributes database.AttrMap) (str
113115 case OpBetween :
114116 return fmt .Sprintf ("%s BETWEEN ? AND ? " , attributes [fieldName ].DataQuery ), values , nil
115117 case OpIn :
116- return fmt .Sprintf ("%s IN (?) " , attributes [fieldName ].DataQuery ), []interface {} {values }, nil
118+ return fmt .Sprintf ("%s IN (?) " , attributes [fieldName ].DataQuery ), []any {values }, nil
117119 case OpNotIn :
118- return fmt .Sprintf ("%s NOT IN (?) " , attributes [fieldName ].DataQuery ), []interface {}{values }, nil
120+ return fmt .Sprintf ("%s NOT IN (?) " , attributes [fieldName ].DataQuery ), []any {values }, nil
121+ case OpNull :
122+ return fmt .Sprintf ("%s IS NULL " , attributes [fieldName ].DataQuery ), []any {}, nil
123+ case OpNotNull :
124+ return fmt .Sprintf ("%s IS NOT NULL " , attributes [fieldName ].DataQuery ), []any {}, nil
119125 default :
120126 return "" , []interface {}{}, errors .Errorf ("Unknown filter : %s" , t .Operator )
121127 }
0 commit comments