Add 2 public funcations to get SqlExpr.expr and SqlExpr.args
This commit is contained in:
parent
7180bd0f27
commit
f6835447cc
10
utils.go
10
utils.go
@ -63,6 +63,16 @@ type SqlExpr struct {
|
|||||||
args []interface{}
|
args []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetExpr get SqlExpr expr
|
||||||
|
func (s *SqlExpr) GetExpr() string {
|
||||||
|
return s.expr
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArgs get SqlExpr args
|
||||||
|
func (s *SqlExpr) GetArgs() []interface{} {
|
||||||
|
return s.args
|
||||||
|
}
|
||||||
|
|
||||||
// Expr generate raw SQL expression, for example:
|
// Expr generate raw SQL expression, for example:
|
||||||
// DB.Model(&product).Update("price", gorm.Expr("price * ? + ?", 2, 100))
|
// DB.Model(&product).Update("price", gorm.Expr("price * ? + ?", 2, 100))
|
||||||
func Expr(expression string, args ...interface{}) *SqlExpr {
|
func Expr(expression string, args ...interface{}) *SqlExpr {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user