2019-04-20 19:49:29 +02:00
|
|
|
package sqlbuilder
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"gotest.tools/assert"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestDeleteUnconditionally(t *testing.T) {
|
2019-05-01 17:25:10 +02:00
|
|
|
_, _, err := table1.DELETE().Sql()
|
2019-04-20 19:49:29 +02:00
|
|
|
assert.Assert(t, err != nil)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestDeleteWithWhere(t *testing.T) {
|
2019-05-01 17:25:10 +02:00
|
|
|
sql, _, err := table1.DELETE().WHERE(table1Col1.EqL(1)).Sql()
|
2019-04-20 19:49:29 +02:00
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
2019-05-01 17:25:10 +02:00
|
|
|
assert.Equal(t, sql, "DELETE FROM db.table1 WHERE table1.col1 = $1;")
|
2019-04-20 19:49:29 +02:00
|
|
|
}
|