MySQL lock and unlock tables statement.

This commit is contained in:
go-jet 2019-08-11 16:55:18 +02:00
parent ee4897a1e2
commit a3ae52c43c
5 changed files with 128 additions and 18 deletions

42
tests/mysql/lock_test.go Normal file
View file

@ -0,0 +1,42 @@
package mysql
import (
"github.com/go-jet/jet/internal/testutils"
. "github.com/go-jet/jet/mysql"
. "github.com/go-jet/jet/tests/.gentestdata/mysql/dvds/table"
"gotest.tools/assert"
"testing"
)
func TestLockRead(t *testing.T) {
query := Customer.LOCK().READ()
testutils.AssertStatementSql(t, query, `
LOCK TABLES dvds.customer READ;
`)
_, err := query.Exec(db)
assert.NilError(t, err)
}
func TestLockWrite(t *testing.T) {
query := Customer.LOCK().WRITE()
testutils.AssertStatementSql(t, query, `
LOCK TABLES dvds.customer WRITE;
`)
_, err := query.Exec(db)
assert.NilError(t, err)
}
func TestUnlockTables(t *testing.T) {
query := UNLOCK_TABLES()
testutils.AssertStatementSql(t, query, `
UNLOCK TABLES;
`)
_, err := query.Exec(db)
assert.NilError(t, err)
}