dal/pkg/filters/Ne.go
Anton Nesterov 43dd4e9234
[ref] name things what they are
Signed-off-by: Anton Nesterov <anton@demiurg.io>
2024-08-11 21:49:49 +02:00

24 lines
416 B
Go

package filters
import "fmt"
type Ne struct {
Ne interface{} `json:"$ne"`
}
func (f Ne) FromJSON(data interface{}) IFilter {
return FromJson[Ne](data)
}
func (f Ne) ToSQLPart(ctx Dialect) string {
if f.Ne == nil {
return ""
}
name := ctx.GetFieldName()
value := ctx.NormalizeValue(f.Ne)
if value == "NULL" {
return fmt.Sprintf("%s IS NOT NULL", name)
}
return fmt.Sprintf("%s != %v", name, value)
}