MCPcopy Index your code
hub / github.com/github/gh-ost / TestTokenizeAlterStatement

Function TestTokenizeAlterStatement

go/sql/parser_test.go:97–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestTokenizeAlterStatement(t *testing.T) {
98 parser := NewAlterTableParser()
99 {
100 alterStatement := "add column t int"
101 tokens := parser.tokenizeAlterStatement(alterStatement)
102 require.Equal(t, []string{"add column t int"}, tokens)
103 }
104 {
105 alterStatement := "add column t int, change column i int"
106 tokens := parser.tokenizeAlterStatement(alterStatement)
107 require.Equal(t, []string{"add column t int", "change column i int"}, tokens)
108 }
109 {
110 alterStatement := "add column t int, change column i int 'some comment'"
111 tokens := parser.tokenizeAlterStatement(alterStatement)
112 require.Equal(t, []string{"add column t int", "change column i int 'some comment'"}, tokens)
113 }
114 {
115 alterStatement := "add column t int, change column i int 'some comment, with comma'"
116 tokens := parser.tokenizeAlterStatement(alterStatement)
117 require.Equal(t, []string{"add column t int", "change column i int 'some comment, with comma'"}, tokens)
118 }
119 {
120 alterStatement := "add column t int, add column d decimal(10,2)"
121 tokens := parser.tokenizeAlterStatement(alterStatement)
122 require.Equal(t, []string{"add column t int", "add column d decimal(10,2)"}, tokens)
123 }
124 {
125 alterStatement := "add column t int, add column e enum('a','b','c')"
126 tokens := parser.tokenizeAlterStatement(alterStatement)
127 require.Equal(t, []string{"add column t int", "add column e enum('a','b','c')"}, tokens)
128 }
129 {
130 alterStatement := "add column t int(11), add column e enum('a','b','c')"
131 tokens := parser.tokenizeAlterStatement(alterStatement)
132 require.Equal(t, []string{"add column t int(11)", "add column e enum('a','b','c')"}, tokens)
133 }
134}
135
136func TestSanitizeQuotesFromAlterStatement(t *testing.T) {
137 parser := NewAlterTableParser()

Callers

nothing calls this directly

Calls 2

NewAlterTableParserFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…