v3.5.0
Changelog for v3.5.0
Support for comparison operations
Starting on 3.5.0 you'll be able to use comparison operators that are compatible across different database engines, see some examples:
// foo = "bar"
db.Cond{
"foo": db.Eq("bar")
}
// foo <= 15
db.Cond{
"foo": db.Lte(15)
}
// foo >= 17
db.Cond{
"foo": db.Gte(17)
}
// foo BETWEEN DATEA AND DATEB
db.Cond{
"foo": db.Between(dateA, dateB)
}
// foo IS NOT NULL
db.Cond{
"foo": db.IsNotNull(),
}
// foo -> 45
db.Cond{
"foo": db.Op("->", 45),
}
This is the full list of comparison functions:
db.Eq(interface{})
db.NotEq(interface{})
db.Gte(interface{})
db.Gt(interface{})
db.Lte(interface{})
db.Lt(interface{})
db.Between(interface{}, interface{})
db.NotBetween(interface{}, interface{})
db.In(interface{})
db.NotIn(interface{})
db.After(time.Time)
db.Before(time.Time)
db.OnOrAfter(time.Time)
db.OnOrBefore(time.Time)
db.Is(interface{})
db.IsNot(interface{})
db.IsNull()
db.IsNotNull()
db.Like(string)
db.NotLike(string)
db.RegExp(string)
db.NotRegExp(string)
db.Op(string, interface{})
The old syntax (db.Cond{"column operator": value}
) will continue to be supported along to the new syntax, no code changes are required to upgrade from 3.4.x.
Thanks
Thank you for using upper-db!