MySQL: Add Where and Limit for Delete statement.
This commit is contained in:
parent
a3ae52c43c
commit
0dd976601e
6 changed files with 91 additions and 29 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-jet/jet/internal/testutils"
|
||||
. "github.com/go-jet/jet/mysql"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/mysql/dvds/table"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/mysql/test_sample/table"
|
||||
"gotest.tools/assert"
|
||||
|
|
@ -204,6 +205,19 @@ func TestUpdateExecContext(t *testing.T) {
|
|||
assert.Error(t, err, "context deadline exceeded")
|
||||
}
|
||||
|
||||
func TestUpdateWithJoin(t *testing.T) {
|
||||
query := table.Staff.
|
||||
INNER_JOIN(table.Address, table.Address.AddressID.EQ(table.Staff.AddressID)).
|
||||
UPDATE(table.Staff.LastName).
|
||||
SET(String("New name")).
|
||||
WHERE(table.Staff.StaffID.EQ(Int(1)))
|
||||
|
||||
//fmt.Println(query.DebugSql())
|
||||
|
||||
_, err := query.Exec(db)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
func setupLinkTableForUpdateTest(t *testing.T) {
|
||||
|
||||
cleanUpLinkTable(t)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue