-
Notifications
You must be signed in to change notification settings - Fork 2
/
delete_test.go
45 lines (41 loc) · 1.14 KB
/
delete_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package sqlparser
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestParseDelete(t *testing.T) {
testcases := []struct {
SQL string
expect string
description string
}{
{
description: "basic",
SQL: "DELETE FROM PRODUCTS",
expect: "DELETE FROM PRODUCTS",
},
{
description: "with qualify",
SQL: "DELETE FROM PRODUCTS WHERE ID = 10",
expect: "DELETE FROM PRODUCTS WHERE ID = 10",
},
{
description: "with aliases",
SQL: "DELETE p FROM PRODUCTS p WHERE p.ID = 10",
expect: "DELETE p FROM PRODUCTS p WHERE p.ID = 10",
},
{
description: "with joins",
SQL: "DELETE p, o FROM PRODUCTS p JOIN OTHER o ON p.ID = o.PRODUCT_ID WHERE p.ID = 10",
expect: "DELETE p, o FROM PRODUCTS p JOIN OTHER o ON p.ID = o.PRODUCT_ID WHERE p.ID = 10",
},
}
//for _, testcase := range testcases[len(testcases)-1:] {
for _, testcase := range testcases {
statement, err := ParseDelete(testcase.SQL)
if !assert.Nil(t, err, testcase.description) {
continue
}
assert.Equal(t, testcase.expect, Stringify(statement), testcase.description)
}
}