Add 2 public funcations to get SqlExpr.expr and SqlExpr.args

This commit is contained in:
aalfadhila 2020-03-03 11:13:12 +03:00 committed by GitHub
parent 7180bd0f27
commit f6835447cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {