qb: update builder advanced assignments
This commit is contained in:
@@ -36,6 +36,36 @@ func TestUpdateBuilder(t *testing.T) {
|
||||
S: "UPDATE cycling.cyclist_name SET id=?,user_uuid=?,firstname=?,stars=? WHERE id=? ",
|
||||
N: []string{"id", "user_uuid", "firstname", "stars", "expr"},
|
||||
},
|
||||
// Add SET SetFunc
|
||||
{
|
||||
B: Update("cycling.cyclist_name").SetFunc("user_uuid", Fn("someFunc", "param_0", "param_1")).Where(w).Set("stars"),
|
||||
S: "UPDATE cycling.cyclist_name SET user_uuid=someFunc(?,?),stars=? WHERE id=? ",
|
||||
N: []string{"param_0", "param_1", "stars", "expr"},
|
||||
},
|
||||
// Add SET Add
|
||||
{
|
||||
B: Update("cycling.cyclist_name").Add("total").Where(w),
|
||||
S: "UPDATE cycling.cyclist_name SET total=total+? WHERE id=? ",
|
||||
N: []string{"total", "expr"},
|
||||
},
|
||||
// Add SET AddNamed
|
||||
{
|
||||
B: Update("cycling.cyclist_name").AddNamed("total", "inc").Where(w),
|
||||
S: "UPDATE cycling.cyclist_name SET total=total+? WHERE id=? ",
|
||||
N: []string{"inc", "expr"},
|
||||
},
|
||||
// Add SET Remove
|
||||
{
|
||||
B: Update("cycling.cyclist_name").Remove("total").Where(w),
|
||||
S: "UPDATE cycling.cyclist_name SET total=total-? WHERE id=? ",
|
||||
N: []string{"total", "expr"},
|
||||
},
|
||||
// Add SET RemoveNamed
|
||||
{
|
||||
B: Update("cycling.cyclist_name").RemoveNamed("total", "dec").Where(w),
|
||||
S: "UPDATE cycling.cyclist_name SET total=total-? WHERE id=? ",
|
||||
N: []string{"dec", "expr"},
|
||||
},
|
||||
// Add WHERE
|
||||
{
|
||||
B: Update("cycling.cyclist_name").Set("id", "user_uuid", "firstname").Where(w, Gt("firstname")),
|
||||
|
||||
Reference in New Issue
Block a user