MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestInsert

Function TestInsert

pkg/sql/ast/dml_test.go:134–220  ·  view source on GitHub ↗

Test Insert node (DML)

(t *testing.T)

Source from the content-addressed store, hash-verified

132
133// Test Insert node (DML)
134func TestInsert(t *testing.T) {
135 tests := []struct {
136 name string
137 ins *Insert
138 wantLiteral string
139 minChildren int
140 }{
141 {
142 name: "simple INSERT with values",
143 ins: &Insert{
144 Table: TableReference{Name: "users"},
145 Columns: []Expression{
146 &Identifier{Name: "name"},
147 &Identifier{Name: "email"},
148 },
149 Values: [][]Expression{
150 {
151 &LiteralValue{Value: "John"},
152 &LiteralValue{Value: "john@example.com"},
153 },
154 },
155 },
156 wantLiteral: "INSERT",
157 minChildren: 5,
158 },
159 {
160 name: "INSERT with multiple rows",
161 ins: &Insert{
162 Table: TableReference{Name: "products"},
163 Columns: []Expression{
164 &Identifier{Name: "name"},
165 &Identifier{Name: "price"},
166 },
167 Values: [][]Expression{
168 {
169 &LiteralValue{Value: "Widget"},
170 &LiteralValue{Value: "9.99"},
171 },
172 {
173 &LiteralValue{Value: "Gadget"},
174 &LiteralValue{Value: "19.99"},
175 },
176 },
177 },
178 wantLiteral: "INSERT",
179 minChildren: 7,
180 },
181 {
182 name: "INSERT with RETURNING",
183 ins: &Insert{
184 Table: TableReference{Name: "users"},
185 Columns: []Expression{
186 &Identifier{Name: "name"},
187 },
188 Values: [][]Expression{
189 {
190 &LiteralValue{Value: "Jane"},
191 },

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
TokenLiteralMethod · 0.65
ErrorfMethod · 0.65
ChildrenMethod · 0.65
statementNodeMethod · 0.65

Tested by

no test coverage detected