2019-08-11 12:13:59 +02:00
|
|
|
package mysql
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestDeleteUnconditionally(t *testing.T) {
|
2019-08-12 12:11:16 +02:00
|
|
|
assertStatementSqlErr(t, table1.DELETE(), `jet: WHERE clause not set`)
|
|
|
|
|
assertStatementSqlErr(t, table1.DELETE().WHERE(nil), `jet: WHERE clause not set`)
|
2019-08-11 12:13:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestDeleteWithWhere(t *testing.T) {
|
2019-08-12 12:11:16 +02:00
|
|
|
assertStatementSql(t, table1.DELETE().WHERE(table1Col1.EQ(Int(1))), `
|
2019-08-11 12:13:59 +02:00
|
|
|
DELETE FROM db.table1
|
|
|
|
|
WHERE table1.col1 = ?;
|
|
|
|
|
`, int64(1))
|
|
|
|
|
}
|
2019-08-11 18:23:02 +02:00
|
|
|
|
|
|
|
|
func TestDeleteWithWhereOrderByLimit(t *testing.T) {
|
2019-08-12 12:11:16 +02:00
|
|
|
assertStatementSql(t, table1.DELETE().WHERE(table1Col1.EQ(Int(1))).ORDER_BY(table1Col1).LIMIT(1), `
|
2019-08-11 18:23:02 +02:00
|
|
|
DELETE FROM db.table1
|
|
|
|
|
WHERE table1.col1 = ?
|
|
|
|
|
ORDER BY table1.col1
|
|
|
|
|
LIMIT ?;
|
|
|
|
|
`, int64(1), int64(1))
|
|
|
|
|
}
|