Debian Codegraph @

internal/integration/reql_tests/reql_mutation_insert_test.go

raw symbols SCIP
1 // Code generated by gen_tests.py and process_polyglot.py.
2 // Do not edit this file directly.
3 // The template for this file is located at:
4 // ../template.go.tpl
5 package reql_tests
6
7 import (
8 "testing"
9 "time"
10
11 "github.com/stretchr/testify/suite"
12 r "gopkg.in/rethinkdb/rethinkdb-go.v6"
13 "gopkg.in/rethinkdb/rethinkdb-go.v6/internal/compare"
14 )
15
16 // Tests insertion into tables
17 func TestMutationInsertSuite(t *testing.T) {
18 suite.Run(t, new(MutationInsertSuite))
19 }
20
21 type MutationInsertSuite struct {
22 suite.Suite
23
24 session *r.Session
25 }
26
27 func (suite *MutationInsertSuite) SetupTest() {
28 suite.T().Log("Setting up MutationInsertSuite")
29 // Use imports to prevent errors
30 _ = time.Time{}
31 _ = compare.AnythingIsFine
32
33 session, err := r.Connect(r.ConnectOpts{
34 Address: url,
35 })
36 suite.Require().NoError(err, "Error returned when connecting to server")
37 suite.session = session
38
39 r.DBDrop("db_mut_ins").Exec(suite.session)
40 err = r.DBCreate("db_mut_ins").Exec(suite.session)
41 suite.Require().NoError(err)
42 err = r.DB("db_mut_ins").Wait().Exec(suite.session)
43 suite.Require().NoError(err)
44
45 r.DB("db_mut_ins").TableDrop("table_test_mutation_insert").Exec(suite.session)
46 err = r.DB("db_mut_ins").TableCreate("table_test_mutation_insert").Exec(suite.session)
47 suite.Require().NoError(err)
48 err = r.DB("db_mut_ins").Table("table_test_mutation_insert").Wait().Exec(suite.session)
49 suite.Require().NoError(err)
50 }
51
52 func (suite *MutationInsertSuite) TearDownSuite() {
53 suite.T().Log("Tearing down MutationInsertSuite")
54
55 if suite.session != nil {
56 r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session)
57 r.DB("db_mut_ins").TableDrop("table_test_mutation_insert").Exec(suite.session)
58 r.DBDrop("db_mut_ins").Exec(suite.session)
59
60 suite.session.Close()
61 }
62 }
63
64 func (suite *MutationInsertSuite) TestCases() {
65 suite.T().Log("Running MutationInsertSuite: Tests insertion into tables")
66
67 table_test_mutation_insert := r.DB("db_mut_ins").Table("table_test_mutation_insert")
68 _ = table_test_mutation_insert // Prevent any noused variable errors
69
70 {
71 // mutation/insert.yaml line #6
72 /* partial({'tables_created':1}) */
73 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1})
74 /* r.db('test').table_create('table_test2_mutation') */
75
76 suite.T().Log("About to run line #6: r.DB('test').TableCreate('table_test2_mutation')")
77
78 runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableCreate("table_test2_mutation"), suite.session, r.RunOpts{
79 GeometryFormat: "raw",
80 GroupFormat: "map",
81 })
82 suite.T().Log("Finished running line #6")
83 }
84
85 // mutation/insert.yaml line #9
86 // table_test_mutation_insert2 = r.db('test').table('table_test2_mutation')
87 suite.T().Log("Possibly executing: var table_test_mutation_insert2 r.Term = r.DB('test').Table('table_test2_mutation')")
88
89 table_test_mutation_insert2 := r.DB("db_mut_ins").Table("table_test2_mutation")
90 _ = table_test_mutation_insert2 // Prevent any noused variable errors
91
92 {
93 // mutation/insert.yaml line #12
94 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
95 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
96 /* table_test_mutation_insert.insert({'id':0,'a':0}) */
97
98 suite.T().Log("About to run line #12: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 0, 'a': 0, })")
99
100 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 0, "a": 0}), suite.session, r.RunOpts{
101 GeometryFormat: "raw",
102 GroupFormat: "map",
103 })
104 suite.T().Log("Finished running line #12")
105 }
106
107 {
108 // mutation/insert.yaml line #14
109 /* 1 */
110 var expected_ int = 1
111 /* table_test_mutation_insert.count() */
112
113 suite.T().Log("About to run line #14: table_test_mutation_insert.Count()")
114
115 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{
116 GeometryFormat: "raw",
117 GroupFormat: "map",
118 })
119 suite.T().Log("Finished running line #14")
120 }
121
122 {
123 // mutation/insert.yaml line #18
124 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
125 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
126 /* table_test_mutation_insert.insert({'id':1, 'a':1}, durability='hard') */
127
128 suite.T().Log("About to run line #18: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 1, 'a': 1, }).OptArgs(r.InsertOpts{Durability: 'hard', })")
129
130 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 1, "a": 1}).OptArgs(r.InsertOpts{Durability: "hard"}), suite.session, r.RunOpts{
131 GeometryFormat: "raw",
132 GroupFormat: "map",
133 })
134 suite.T().Log("Finished running line #18")
135 }
136
137 {
138 // mutation/insert.yaml line #22
139 /* 2 */
140 var expected_ int = 2
141 /* table_test_mutation_insert.count() */
142
143 suite.T().Log("About to run line #22: table_test_mutation_insert.Count()")
144
145 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{
146 GeometryFormat: "raw",
147 GroupFormat: "map",
148 })
149 suite.T().Log("Finished running line #22")
150 }
151
152 {
153 // mutation/insert.yaml line #26
154 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
155 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
156 /* table_test_mutation_insert.insert({'id':2, 'a':2}, durability='soft') */
157
158 suite.T().Log("About to run line #26: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'a': 2, }).OptArgs(r.InsertOpts{Durability: 'soft', })")
159
160 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "a": 2}).OptArgs(r.InsertOpts{Durability: "soft"}), suite.session, r.RunOpts{
161 GeometryFormat: "raw",
162 GroupFormat: "map",
163 })
164 suite.T().Log("Finished running line #26")
165 }
166
167 {
168 // mutation/insert.yaml line #30
169 /* 3 */
170 var expected_ int = 3
171 /* table_test_mutation_insert.count() */
172
173 suite.T().Log("About to run line #30: table_test_mutation_insert.Count()")
174
175 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{
176 GeometryFormat: "raw",
177 GroupFormat: "map",
178 })
179 suite.T().Log("Finished running line #30")
180 }
181
182 {
183 // mutation/insert.yaml line #34
184 /* err('ReqlQueryLogicError', 'Durability option `wrong` unrecognized (options are "hard" and "soft").', [0]) */
185 var expected_ Err = err("ReqlQueryLogicError", "Durability option `wrong` unrecognized (options are \"hard\" and \"soft\").")
186 /* table_test_mutation_insert.insert({'id':3, 'a':3}, durability='wrong') */
187
188 suite.T().Log("About to run line #34: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 3, 'a': 3, }).OptArgs(r.InsertOpts{Durability: 'wrong', })")
189
190 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 3, "a": 3}).OptArgs(r.InsertOpts{Durability: "wrong"}), suite.session, r.RunOpts{
191 GeometryFormat: "raw",
192 GroupFormat: "map",
193 })
194 suite.T().Log("Finished running line #34")
195 }
196
197 {
198 // mutation/insert.yaml line #38
199 /* 3 */
200 var expected_ int = 3
201 /* table_test_mutation_insert.count() */
202
203 suite.T().Log("About to run line #38: table_test_mutation_insert.Count()")
204
205 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Count(), suite.session, r.RunOpts{
206 GeometryFormat: "raw",
207 GroupFormat: "map",
208 })
209 suite.T().Log("Finished running line #38")
210 }
211
212 {
213 // mutation/insert.yaml line #42
214 /* {'deleted':1,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */
215 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 1, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0}
216 /* table_test_mutation_insert.get(2).delete() */
217
218 suite.T().Log("About to run line #42: table_test_mutation_insert.Get(2).Delete()")
219
220 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2).Delete(), suite.session, r.RunOpts{
221 GeometryFormat: "raw",
222 GroupFormat: "map",
223 })
224 suite.T().Log("Finished running line #42")
225 }
226
227 {
228 // mutation/insert.yaml line #46
229 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':2} */
230 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 2}
231 /* table_test_mutation_insert.insert([{'id':2,'a':2}, {'id':3,'a':3}]) */
232
233 suite.T().Log("About to run line #46: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 2, 'a': 2, }, map[interface{}]interface{}{'id': 3, 'a': 3, }})")
234
235 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 2, "a": 2}, map[interface{}]interface{}{"id": 3, "a": 3}}), suite.session, r.RunOpts{
236 GeometryFormat: "raw",
237 GroupFormat: "map",
238 })
239 suite.T().Log("Finished running line #46")
240 }
241
242 {
243 // mutation/insert.yaml line #50
244 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':4} */
245 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 4}
246 /* table_test_mutation_insert2.insert(table_test_mutation_insert) */
247
248 suite.T().Log("About to run line #50: table_test_mutation_insert2.Insert(table_test_mutation_insert)")
249
250 runAndAssert(suite.Suite, expected_, table_test_mutation_insert2.Insert(table_test_mutation_insert), suite.session, r.RunOpts{
251 GeometryFormat: "raw",
252 GroupFormat: "map",
253 })
254 suite.T().Log("Finished running line #50")
255 }
256
257 {
258 // mutation/insert.yaml line #54
259 /* {'first_error':"Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}",'deleted':0,'replaced':0,'unchanged':0,'errors':1,'skipped':0,'inserted':0} */
260 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}", "deleted": 0, "replaced": 0, "unchanged": 0, "errors": 1, "skipped": 0, "inserted": 0}
261 /* table_test_mutation_insert.insert({'id':2,'b':20}) */
262
263 suite.T().Log("About to run line #54: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, })")
264
265 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}), suite.session, r.RunOpts{
266 GeometryFormat: "raw",
267 GroupFormat: "map",
268 })
269 suite.T().Log("Finished running line #54")
270 }
271
272 {
273 // mutation/insert.yaml line #58
274 /* {'first_error':"Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}",'deleted':0,'replaced':0,'unchanged':0,'errors':1,'skipped':0,'inserted':0} */
275 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"first_error": "Duplicate primary key `id`:\n{\n\t\"a\":\t2,\n\t\"id\":\t2\n}\n{\n\t\"b\":\t20,\n\t\"id\":\t2\n}", "deleted": 0, "replaced": 0, "unchanged": 0, "errors": 1, "skipped": 0, "inserted": 0}
276 /* table_test_mutation_insert.insert({'id':2,'b':20}, conflict='error') */
277
278 suite.T().Log("About to run line #58: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'error', })")
279
280 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}).OptArgs(r.InsertOpts{Conflict: "error"}), suite.session, r.RunOpts{
281 GeometryFormat: "raw",
282 GroupFormat: "map",
283 })
284 suite.T().Log("Finished running line #58")
285 }
286
287 {
288 // mutation/insert.yaml line #64
289 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
290 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
291 /* table_test_mutation_insert.insert({'id':15,'b':20}, conflict='error') */
292
293 suite.T().Log("About to run line #64: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 15, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'error', })")
294
295 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 15, "b": 20}).OptArgs(r.InsertOpts{Conflict: "error"}), suite.session, r.RunOpts{
296 GeometryFormat: "raw",
297 GroupFormat: "map",
298 })
299 suite.T().Log("Finished running line #64")
300 }
301
302 {
303 // mutation/insert.yaml line #69
304 /* {'id':15,'b':20} */
305 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 15, "b": 20}
306 /* table_test_mutation_insert.get(15) */
307
308 suite.T().Log("About to run line #69: table_test_mutation_insert.Get(15)")
309
310 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(15), suite.session, r.RunOpts{
311 GeometryFormat: "raw",
312 GroupFormat: "map",
313 })
314 suite.T().Log("Finished running line #69")
315 }
316
317 {
318 // mutation/insert.yaml line #73
319 /* {'deleted':0,'replaced':1,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */
320 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 1, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0}
321 /* table_test_mutation_insert.insert({'id':2,'b':20}, conflict='replace') */
322
323 suite.T().Log("About to run line #73: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })")
324
325 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{
326 GeometryFormat: "raw",
327 GroupFormat: "map",
328 })
329 suite.T().Log("Finished running line #73")
330 }
331
332 {
333 // mutation/insert.yaml line #78
334 /* {'id':2,'b':20} */
335 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 2, "b": 20}
336 /* table_test_mutation_insert.get(2) */
337
338 suite.T().Log("About to run line #78: table_test_mutation_insert.Get(2)")
339
340 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2), suite.session, r.RunOpts{
341 GeometryFormat: "raw",
342 GroupFormat: "map",
343 })
344 suite.T().Log("Finished running line #78")
345 }
346
347 {
348 // mutation/insert.yaml line #82
349 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
350 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
351 /* table_test_mutation_insert.insert({'id':20,'b':20}, conflict='replace') */
352
353 suite.T().Log("About to run line #82: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 20, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })")
354
355 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 20, "b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{
356 GeometryFormat: "raw",
357 GroupFormat: "map",
358 })
359 suite.T().Log("Finished running line #82")
360 }
361
362 {
363 // mutation/insert.yaml line #87
364 /* {'id':20,'b':20} */
365 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 20, "b": 20}
366 /* table_test_mutation_insert.get(20) */
367
368 suite.T().Log("About to run line #87: table_test_mutation_insert.Get(20)")
369
370 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(20), suite.session, r.RunOpts{
371 GeometryFormat: "raw",
372 GroupFormat: "map",
373 })
374 suite.T().Log("Finished running line #87")
375 }
376
377 {
378 // mutation/insert.yaml line #91
379 /* {'deleted':0,'replaced':1,'unchanged':0,'errors':0,'skipped':0,'inserted':0} */
380 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 1, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 0}
381 /* table_test_mutation_insert.insert({'id':2,'c':30}, conflict='update') */
382
383 suite.T().Log("About to run line #91: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 2, 'c': 30, }).OptArgs(r.InsertOpts{Conflict: 'update', })")
384
385 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 2, "c": 30}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{
386 GeometryFormat: "raw",
387 GroupFormat: "map",
388 })
389 suite.T().Log("Finished running line #91")
390 }
391
392 {
393 // mutation/insert.yaml line #96
394 /* {'id':2, 'b':20, 'c':30} */
395 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 2, "b": 20, "c": 30}
396 /* table_test_mutation_insert.get(2) */
397
398 suite.T().Log("About to run line #96: table_test_mutation_insert.Get(2)")
399
400 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(2), suite.session, r.RunOpts{
401 GeometryFormat: "raw",
402 GroupFormat: "map",
403 })
404 suite.T().Log("Finished running line #96")
405 }
406
407 {
408 // mutation/insert.yaml line #100
409 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
410 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
411 /* table_test_mutation_insert.insert({'id':30,'b':20}, conflict='update') */
412
413 suite.T().Log("About to run line #100: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 30, 'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'update', })")
414
415 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 30, "b": 20}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{
416 GeometryFormat: "raw",
417 GroupFormat: "map",
418 })
419 suite.T().Log("Finished running line #100")
420 }
421
422 {
423 // mutation/insert.yaml line #105
424 /* {'id':30,'b':20} */
425 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 30, "b": 20}
426 /* table_test_mutation_insert.get(30) */
427
428 suite.T().Log("About to run line #105: table_test_mutation_insert.Get(30)")
429
430 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(30), suite.session, r.RunOpts{
431 GeometryFormat: "raw",
432 GroupFormat: "map",
433 })
434 suite.T().Log("Finished running line #105")
435 }
436
437 {
438 // mutation/insert.yaml line #109
439 /* err('ReqlQueryLogicError', 'Conflict option `wrong` unrecognized (options are "error", "replace" and "update").', [0]) */
440 var expected_ Err = err("ReqlQueryLogicError", "Conflict option `wrong` unrecognized (options are \"error\", \"replace\" and \"update\").")
441 /* table_test_mutation_insert.insert({'id':3, 'a':3}, conflict='wrong') */
442
443 suite.T().Log("About to run line #109: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 3, 'a': 3, }).OptArgs(r.InsertOpts{Conflict: 'wrong', })")
444
445 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 3, "a": 3}).OptArgs(r.InsertOpts{Conflict: "wrong"}), suite.session, r.RunOpts{
446 GeometryFormat: "raw",
447 GroupFormat: "map",
448 })
449 suite.T().Log("Finished running line #109")
450 }
451
452 // mutation/insert.yaml line #120
453 // table_test_mutation_insertpkey = r.db('test').table('testpkey_mutation_insert')
454 suite.T().Log("Possibly executing: var table_test_mutation_insertpkey r.Term = r.DB('test').Table('testpkey_mutation_insert')")
455
456 table_test_mutation_insertpkey := r.DB("db_mut_ins").Table("testpkey_mutation_insert")
457 _ = table_test_mutation_insertpkey // Prevent any noused variable errors
458
459 {
460 // mutation/insert.yaml line #115
461 /* partial({'tables_created':1}) */
462 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1})
463 /* r.db('test').table_create('testpkey_mutation_insert', primary_key='foo') */
464
465 suite.T().Log("About to run line #115: r.DB('test').TableCreate('testpkey_mutation_insert').OptArgs(r.TableCreateOpts{PrimaryKey: 'foo', })")
466
467 runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableCreate("testpkey_mutation_insert").OptArgs(r.TableCreateOpts{PrimaryKey: "foo"}), suite.session, r.RunOpts{
468 GeometryFormat: "raw",
469 GroupFormat: "map",
470 })
471 suite.T().Log("Finished running line #115")
472 }
473
474 {
475 // mutation/insert.yaml line #122
476 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
477 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
478 /* table_test_mutation_insertpkey.insert({}) */
479
480 suite.T().Log("About to run line #122: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{})")
481
482 runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{}), suite.session, r.RunOpts{
483 GeometryFormat: "raw",
484 GroupFormat: "map",
485 })
486 suite.T().Log("Finished running line #122")
487 }
488
489 {
490 // mutation/insert.yaml line #125
491 /* [{'foo':uuid()}] */
492 var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"foo": compare.IsUUID()}}
493 /* table_test_mutation_insertpkey */
494
495 suite.T().Log("About to run line #125: table_test_mutation_insertpkey")
496
497 runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey, suite.session, r.RunOpts{
498 GeometryFormat: "raw",
499 GroupFormat: "map",
500 })
501 suite.T().Log("Finished running line #125")
502 }
503
504 {
505 // mutation/insert.yaml line #129
506 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
507 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
508 /* table_test_mutation_insertpkey.insert({'b':20}, conflict='replace') */
509
510 suite.T().Log("About to run line #129: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'replace', })")
511
512 runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{"b": 20}).OptArgs(r.InsertOpts{Conflict: "replace"}), suite.session, r.RunOpts{
513 GeometryFormat: "raw",
514 GroupFormat: "map",
515 })
516 suite.T().Log("Finished running line #129")
517 }
518
519 {
520 // mutation/insert.yaml line #135
521 /* {'deleted':0,'replaced':0,'generated_keys':arrlen(1,uuid()),'unchanged':0,'errors':0,'skipped':0,'inserted':1} */
522 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "generated_keys": arrlen(1, compare.IsUUID()), "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 1}
523 /* table_test_mutation_insertpkey.insert({'b':20}, conflict='update') */
524
525 suite.T().Log("About to run line #135: table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{'b': 20, }).OptArgs(r.InsertOpts{Conflict: 'update', })")
526
527 runAndAssert(suite.Suite, expected_, table_test_mutation_insertpkey.Insert(map[interface{}]interface{}{"b": 20}).OptArgs(r.InsertOpts{Conflict: "update"}), suite.session, r.RunOpts{
528 GeometryFormat: "raw",
529 GroupFormat: "map",
530 })
531 suite.T().Log("Finished running line #135")
532 }
533
534 {
535 // mutation/insert.yaml line #140
536 /* partial({'tables_dropped':1}) */
537 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1})
538 /* r.db('test').table_drop('testpkey_mutation_insert') */
539
540 suite.T().Log("About to run line #140: r.DB('test').TableDrop('testpkey_mutation_insert')")
541
542 runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableDrop("testpkey_mutation_insert"), suite.session, r.RunOpts{
543 GeometryFormat: "raw",
544 GroupFormat: "map",
545 })
546 suite.T().Log("Finished running line #140")
547 }
548
549 {
550 // mutation/insert.yaml line #144
551 /* {'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':7} */
552 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"deleted": 0, "replaced": 0, "unchanged": 0, "errors": 0, "skipped": 0, "inserted": 7}
553 /* table_test_mutation_insert.for_each(lambda row: table_test_mutation_insert2.insert(row.merge({'id':row['id'] + 100 })) ) */
554
555 suite.T().Log("About to run line #144: table_test_mutation_insert.ForEach(func(row r.Term) interface{} { return table_test_mutation_insert2.Insert(row.Merge(map[interface{}]interface{}{'id': row.AtIndex('id').Add(100), }))})")
556
557 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.ForEach(func(row r.Term) interface{} {
558 return table_test_mutation_insert2.Insert(row.Merge(map[interface{}]interface{}{"id": row.AtIndex("id").Add(100)}))
559 }), suite.session, r.RunOpts{
560 GeometryFormat: "raw",
561 GroupFormat: "map",
562 })
563 suite.T().Log("Finished running line #144")
564 }
565
566 {
567 // mutation/insert.yaml line #150
568 /* partial({'errors':1,'first_error':'`r.minval` and `r.maxval` cannot be written to disk.'}) */
569 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 1, "first_error": "`r.minval` and `r.maxval` cannot be written to disk."})
570 /* table_test_mutation_insert.insert({'value':r.minval}) */
571
572 suite.T().Log("About to run line #150: table_test_mutation_insert.Insert(map[interface{}]interface{}{'value': r.MinVal, })")
573
574 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"value": r.MinVal}), suite.session, r.RunOpts{
575 GeometryFormat: "raw",
576 GroupFormat: "map",
577 })
578 suite.T().Log("Finished running line #150")
579 }
580
581 {
582 // mutation/insert.yaml line #154
583 /* partial({'errors':1,'first_error':'`r.minval` and `r.maxval` cannot be written to disk.'}) */
584 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 1, "first_error": "`r.minval` and `r.maxval` cannot be written to disk."})
585 /* table_test_mutation_insert.insert({'value':r.maxval}) */
586
587 suite.T().Log("About to run line #154: table_test_mutation_insert.Insert(map[interface{}]interface{}{'value': r.MaxVal, })")
588
589 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"value": r.MaxVal}), suite.session, r.RunOpts{
590 GeometryFormat: "raw",
591 GroupFormat: "map",
592 })
593 suite.T().Log("Finished running line #154")
594 }
595
596 {
597 // mutation/insert.yaml line #159
598 /* {'changes': [{'new_val': {'id': 666}, 'old_val': None},{'error': 'Duplicate primary key `id`:\n{\n\t"id":\t666\n}\n{\n\t"id":\t666\n}','new_val': {'id': 666},'old_val': {'id': 666}}],'deleted': 0,'errors': 1,'first_error': 'Duplicate primary key `id`:\n{\n\t"id":\t666\n}\n{\n\t"id":\t666\n}','inserted': 1,'replaced': 0,'skipped': 0,'unchanged': 0} */
599 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 666}, "old_val": nil}, map[interface{}]interface{}{"error": "Duplicate primary key `id`:\n{\n\t\"id\":\t666\n}\n{\n\t\"id\":\t666\n}", "new_val": map[interface{}]interface{}{"id": 666}, "old_val": map[interface{}]interface{}{"id": 666}}}, "deleted": 0, "errors": 1, "first_error": "Duplicate primary key `id`:\n{\n\t\"id\":\t666\n}\n{\n\t\"id\":\t666\n}", "inserted": 1, "replaced": 0, "skipped": 0, "unchanged": 0}
600 /* table_test_mutation_insert.insert([{'id':666}, {'id':666}], return_changes="always") */
601
602 suite.T().Log("About to run line #159: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 666, }, map[interface{}]interface{}{'id': 666, }}).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
603
604 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 666}, map[interface{}]interface{}{"id": 666}}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
605 GeometryFormat: "raw",
606 GroupFormat: "map",
607 })
608 suite.T().Log("Finished running line #159")
609 }
610
611 {
612 // mutation/insert.yaml line #163
613 /* partial({'changes':[{'old_val': None, 'new_val': {'id': 100+i, 'ordered-num': i}} for i in range(1,100)] }) */
614 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} {
615 res := []interface{}{}
616 for iterator_ := 1; iterator_ < 100; iterator_++ {
617 i := iterator_
618 res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}})
619 }
620 return res
621 }())})
622 /* table_test_mutation_insert.insert([{'id':100+i, 'ordered-num':i} for i in range(1,100)], return_changes="always") */
623
624 suite.T().Log("About to run line #163: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
625
626 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} {
627 res := []interface{}{}
628 for iterator_ := 1; iterator_ < 100; iterator_++ {
629 i := iterator_
630 res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i})
631 }
632 return res
633 }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
634 GeometryFormat: "raw",
635 GroupFormat: "map",
636 })
637 suite.T().Log("Finished running line #163")
638 }
639
640 {
641 // mutation/insert.yaml line #167
642 /* partial({'changes':[{'old_val': None, 'new_val': {'id': [1,"blah", 200+i], 'ordered-num': i}} for i in range(1,100)] }) */
643 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} {
644 res := []interface{}{}
645 for iterator_ := 1; iterator_ < 100; iterator_++ {
646 i := iterator_
647 res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": []interface{}{1, "blah", 200 + i}, "ordered-num": i}})
648 }
649 return res
650 }())})
651 /* table_test_mutation_insert.insert([{'id':[1, "blah", 200+i], 'ordered-num':i} for i in range(1,100)], return_changes="always") */
652
653 suite.T().Log("About to run line #167: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': []interface{}{1, 'blah', r.Add(200, i)}, 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
654
655 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} {
656 res := []interface{}{}
657 for iterator_ := 1; iterator_ < 100; iterator_++ {
658 i := iterator_
659 res = append(res, map[interface{}]interface{}{"id": []interface{}{1, "blah", r.Add(200, i)}, "ordered-num": i})
660 }
661 return res
662 }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
663 GeometryFormat: "raw",
664 GroupFormat: "map",
665 })
666 suite.T().Log("Finished running line #167")
667 }
668
669 {
670 // mutation/insert.yaml line #171
671 /* partial({'changes':[{'old_val': None, 'new_val': {'id': [1,"blah", 300+i], 'ordered-num': i}} for i in range(1,100)] }) */
672 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} {
673 res := []interface{}{}
674 for iterator_ := 1; iterator_ < 100; iterator_++ {
675 i := iterator_
676 res = append(res, map[interface{}]interface{}{"old_val": nil, "new_val": map[interface{}]interface{}{"id": []interface{}{1, "blah", 300 + i}, "ordered-num": i}})
677 }
678 return res
679 }())})
680 /* table_test_mutation_insert.insert([{'id':[1, "blah", 300+i], 'ordered-num':i} for i in range(1,100)], return_changes=true) */
681
682 suite.T().Log("About to run line #171: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': []interface{}{1, 'blah', r.Add(300, i)}, 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: true, })")
683
684 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} {
685 res := []interface{}{}
686 for iterator_ := 1; iterator_ < 100; iterator_++ {
687 i := iterator_
688 res = append(res, map[interface{}]interface{}{"id": []interface{}{1, "blah", r.Add(300, i)}, "ordered-num": i})
689 }
690 return res
691 }())).OptArgs(r.InsertOpts{ReturnChanges: true}), suite.session, r.RunOpts{
692 GeometryFormat: "raw",
693 GroupFormat: "map",
694 })
695 suite.T().Log("Finished running line #171")
696 }
697
698 {
699 // mutation/insert.yaml line #175
700 /* partial({'changes':[{'old_val': {'id':100+i, 'ordered-num':i}, 'new_val': {'id':100+i, 'ordered-num':i}, 'error':'Duplicate primary key `id`:\n{\n\t"id":\t'+str(100+i)+',\n\t"ordered-num":\t'+str(i)+'\n}\n{\n\t"id":\t'+str(100+i)+',\n\t"ordered-num":\t'+str(i)+'\n}'} for i in range(1,100)]}) */
701 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": (func() []interface{} {
702 res := []interface{}{}
703 for iterator_ := 1; iterator_ < 100; iterator_++ {
704 i := iterator_
705 res = append(res, map[interface{}]interface{}{"old_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}, "new_val": map[interface{}]interface{}{"id": 100 + i, "ordered-num": i}, "error": "Duplicate primary key `id`:\n{\n\t\"id\":\t" + str(100+i) + ",\n\t\"ordered-num\":\t" + str(i) + "\n}\n{\n\t\"id\":\t" + str(100+i) + ",\n\t\"ordered-num\":\t" + str(i) + "\n}"})
706 }
707 return res
708 }())})
709 /* table_test_mutation_insert.insert([{'id':100 + i, 'ordered-num':i} for i in range(1,100)], return_changes="always") */
710
711 suite.T().Log("About to run line #175: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
712
713 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} {
714 res := []interface{}{}
715 for iterator_ := 1; iterator_ < 100; iterator_++ {
716 i := iterator_
717 res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i})
718 }
719 return res
720 }())).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
721 GeometryFormat: "raw",
722 GroupFormat: "map",
723 })
724 suite.T().Log("Finished running line #175")
725 }
726
727 {
728 // mutation/insert.yaml line #179
729 /* {'changes': [{'error': 'Duplicate primary key `id`:\n{\n\t"id":\t123,\n\t"ordered-num":\t23\n}\n{\n\t"id":\t123\n}', 'new_val': {'id': 123, 'ordered-num': 23}, 'old_val': {'id': 123, 'ordered-num': 23}}, {'error': 'Primary key too long (max 127 characters): "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"', 'new_val': None, 'old_val': None}, {'new_val': {'id': 321}, 'old_val': None}], 'deleted': 0, 'errors': 2, 'first_error': 'Primary key too long (max 127 characters): "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"', 'inserted': 1, 'replaced': 0, 'skipped': 0, 'unchanged': 0} */
730 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"error": "Duplicate primary key `id`:\n{\n\t\"id\":\t123,\n\t\"ordered-num\":\t23\n}\n{\n\t\"id\":\t123\n}", "new_val": map[interface{}]interface{}{"id": 123, "ordered-num": 23}, "old_val": map[interface{}]interface{}{"id": 123, "ordered-num": 23}}, map[interface{}]interface{}{"error": "Primary key too long (max 127 characters): \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", "new_val": nil, "old_val": nil}, map[interface{}]interface{}{"new_val": map[interface{}]interface{}{"id": 321}, "old_val": nil}}, "deleted": 0, "errors": 2, "first_error": "Primary key too long (max 127 characters): \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"", "inserted": 1, "replaced": 0, "skipped": 0, "unchanged": 0}
731 /* table_test_mutation_insert.insert([{'id':123}, {'id':'a'*500}, {'id':321}], return_changes="always") */
732
733 suite.T().Log("About to run line #179: table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{'id': 123, }, map[interface{}]interface{}{'id': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', }, map[interface{}]interface{}{'id': 321, }}).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
734
735 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert([]interface{}{map[interface{}]interface{}{"id": 123}, map[interface{}]interface{}{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, map[interface{}]interface{}{"id": 321}}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
736 GeometryFormat: "raw",
737 GroupFormat: "map",
738 })
739 suite.T().Log("Finished running line #179")
740 }
741
742 {
743 // mutation/insert.yaml line #183
744 /* partial({'changes':[]}) */
745 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": []interface{}{}})
746 /* table_test_mutation_insert.insert([{'id':100 + i, 'ordered-num':i} for i in range(1,100)], return_changes=true) */
747
748 suite.T().Log("About to run line #183: table_test_mutation_insert.Insert((func() []interface{} {\n res := []interface{}{}\n for iterator_ := 1; iterator_ < 100; iterator_++ {\n i := iterator_\n res = append(res, map[interface{}]interface{}{'id': r.Add(100, i), 'ordered-num': i, })\n }\n return res\n}())).OptArgs(r.InsertOpts{ReturnChanges: true, })")
749
750 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert((func() []interface{} {
751 res := []interface{}{}
752 for iterator_ := 1; iterator_ < 100; iterator_++ {
753 i := iterator_
754 res = append(res, map[interface{}]interface{}{"id": r.Add(100, i), "ordered-num": i})
755 }
756 return res
757 }())).OptArgs(r.InsertOpts{ReturnChanges: true}), suite.session, r.RunOpts{
758 GeometryFormat: "raw",
759 GroupFormat: "map",
760 })
761 suite.T().Log("Finished running line #183")
762 }
763
764 {
765 // mutation/insert.yaml line #186
766 /* partial({'changes': [{'old_val': None, 'new_val': None, 'error': '`r.minval` and `r.maxval` cannot be written to disk.'}]}) */
767 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"changes": []interface{}{map[interface{}]interface{}{"old_val": nil, "new_val": nil, "error": "`r.minval` and `r.maxval` cannot be written to disk."}}})
768 /* table_test_mutation_insert.insert({'a':r.minval}, return_changes="always") */
769
770 suite.T().Log("About to run line #186: table_test_mutation_insert.Insert(map[interface{}]interface{}{'a': r.MinVal, }).OptArgs(r.InsertOpts{ReturnChanges: 'always', })")
771
772 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"a": r.MinVal}).OptArgs(r.InsertOpts{ReturnChanges: "always"}), suite.session, r.RunOpts{
773 GeometryFormat: "raw",
774 GroupFormat: "map",
775 })
776 suite.T().Log("Finished running line #186")
777 }
778
779 {
780 // mutation/insert.yaml line #192
781 /* partial({'inserted':1}) */
782 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"inserted": 1})
783 /* table_test_mutation_insert.insert({'id':42, 'foo':1, 'bar':1}) */
784
785 suite.T().Log("About to run line #192: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 1, 'bar': 1, })")
786
787 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 1}), suite.session, r.RunOpts{
788 GeometryFormat: "raw",
789 GroupFormat: "map",
790 })
791 suite.T().Log("Finished running line #192")
792 }
793
794 {
795 // mutation/insert.yaml line #194
796 /* partial({'replaced':1}) */
797 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"replaced": 1})
798 /* table_test_mutation_insert.insert({'id':42, 'foo':5, 'bar':5}, conflict=lambda id, old_row, new_row: old_row.merge(new_row.pluck("bar"))) */
799
800 suite.T().Log("About to run line #194: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 5, 'bar': 5, }).OptArgs(r.InsertOpts{Conflict: func(id r.Term, old_row r.Term, new_row r.Term) interface{} { return old_row.Merge(new_row.Pluck('bar'))}, })")
801
802 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 5, "bar": 5}).OptArgs(r.InsertOpts{Conflict: func(id r.Term, old_row r.Term, new_row r.Term) interface{} {
803 return old_row.Merge(new_row.Pluck("bar"))
804 }}), suite.session, r.RunOpts{
805 GeometryFormat: "raw",
806 GroupFormat: "map",
807 })
808 suite.T().Log("Finished running line #194")
809 }
810
811 {
812 // mutation/insert.yaml line #196
813 /* {'id':42, 'foo':1, 'bar':5} */
814 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 5}
815 /* table_test_mutation_insert.get(42) */
816
817 suite.T().Log("About to run line #196: table_test_mutation_insert.Get(42)")
818
819 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(42), suite.session, r.RunOpts{
820 GeometryFormat: "raw",
821 GroupFormat: "map",
822 })
823 suite.T().Log("Finished running line #196")
824 }
825
826 {
827 // mutation/insert.yaml line #214
828 /* partial({'first_error': 'Inserted value must be an OBJECT (got NUMBER):\n2'}) */
829 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"first_error": "Inserted value must be an OBJECT (got NUMBER):\n2"})
830 /* table_test_mutation_insert.insert({'id':42, 'foo':1, 'bar':1}, conflict=lambda a,b,c: 2) */
831
832 suite.T().Log("About to run line #214: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, 'foo': 1, 'bar': 1, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return 2}, })")
833
834 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42, "foo": 1, "bar": 1}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return 2 }}), suite.session, r.RunOpts{
835 GeometryFormat: "raw",
836 GroupFormat: "map",
837 })
838 suite.T().Log("Finished running line #214")
839 }
840
841 {
842 // mutation/insert.yaml line #218
843 /* err("ReqlQueryLogicError", "The conflict function passed to `insert` should expect 3 arguments.") */
844 var expected_ Err = err("ReqlQueryLogicError", "The conflict function passed to `insert` should expect 3 arguments.")
845 /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b: a) */
846
847 suite.T().Log("About to run line #218: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term) interface{} { return a}, })")
848
849 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term) interface{} { return a }}), suite.session, r.RunOpts{
850 GeometryFormat: "raw",
851 GroupFormat: "map",
852 })
853 suite.T().Log("Finished running line #218")
854 }
855
856 {
857 // mutation/insert.yaml line #222
858 /* err("ReqlQueryLogicError", "The conflict function passed to `insert` must be deterministic.") */
859 var expected_ Err = err("ReqlQueryLogicError", "The conflict function passed to `insert` must be deterministic.")
860 /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b,c: table_test_mutation_insert.get(42)) */
861
862 suite.T().Log("About to run line #222: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return table_test_mutation_insert.Get(42)}, })")
863
864 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return table_test_mutation_insert.Get(42) }}), suite.session, r.RunOpts{
865 GeometryFormat: "raw",
866 GroupFormat: "map",
867 })
868 suite.T().Log("Finished running line #222")
869 }
870
871 {
872 // mutation/insert.yaml line #225
873 /* partial({'replaced': 1}) */
874 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"replaced": 1})
875 /* table_test_mutation_insert.insert({'id':42}, conflict=lambda a,b,c: {'id':42, 'num':'424'}) */
876
877 suite.T().Log("About to run line #225: table_test_mutation_insert.Insert(map[interface{}]interface{}{'id': 42, }).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} { return map[interface{}]interface{}{'id': 42, 'num': '424', }}, })")
878
879 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Insert(map[interface{}]interface{}{"id": 42}).OptArgs(r.InsertOpts{Conflict: func(a r.Term, b r.Term, c r.Term) interface{} {
880 return map[interface{}]interface{}{"id": 42, "num": "424"}
881 }}), suite.session, r.RunOpts{
882 GeometryFormat: "raw",
883 GroupFormat: "map",
884 })
885 suite.T().Log("Finished running line #225")
886 }
887
888 {
889 // mutation/insert.yaml line #227
890 /* {'id':42, 'num':'424'} */
891 var expected_ map[interface{}]interface{} = map[interface{}]interface{}{"id": 42, "num": "424"}
892 /* table_test_mutation_insert.get(42) */
893
894 suite.T().Log("About to run line #227: table_test_mutation_insert.Get(42)")
895
896 runAndAssert(suite.Suite, expected_, table_test_mutation_insert.Get(42), suite.session, r.RunOpts{
897 GeometryFormat: "raw",
898 GroupFormat: "map",
899 })
900 suite.T().Log("Finished running line #227")
901 }
902
903 {
904 // mutation/insert.yaml line #231
905 /* err('ReqlQueryLogicError','Cannot convert `r.minval` to JSON.') */
906 var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.minval` to JSON.")
907 /* r.minval */
908
909 suite.T().Log("About to run line #231: r.MinVal")
910
911 runAndAssert(suite.Suite, expected_, r.MinVal, suite.session, r.RunOpts{
912 GeometryFormat: "raw",
913 GroupFormat: "map",
914 })
915 suite.T().Log("Finished running line #231")
916 }
917
918 {
919 // mutation/insert.yaml line #234
920 /* err('ReqlQueryLogicError','Cannot convert `r.maxval` to JSON.') */
921 var expected_ Err = err("ReqlQueryLogicError", "Cannot convert `r.maxval` to JSON.")
922 /* r.maxval */
923
924 suite.T().Log("About to run line #234: r.MaxVal")
925
926 runAndAssert(suite.Suite, expected_, r.MaxVal, suite.session, r.RunOpts{
927 GeometryFormat: "raw",
928 GroupFormat: "map",
929 })
930 suite.T().Log("Finished running line #234")
931 }
932
933 {
934 // mutation/insert.yaml line #238
935 /* partial({'tables_dropped':1}) */
936 var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1})
937 /* r.db('test').table_drop('table_test2_mutation') */
938
939 suite.T().Log("About to run line #238: r.DB('test').TableDrop('table_test2_mutation')")
940
941 runAndAssert(suite.Suite, expected_, r.DB("db_mut_ins").TableDrop("table_test2_mutation"), suite.session, r.RunOpts{
942 GeometryFormat: "raw",
943 GroupFormat: "map",
944 })
945 suite.T().Log("Finished running line #238")
946 }
947 }