| 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 that manipulation data in tables |
| 17 | func TestJoinsSuite(t *testing.T) { |
| 18 | suite.Run(t, new(JoinsSuite)) |
| 19 | } |
| 20 | |
| 21 | type JoinsSuite struct { |
| 22 | suite.Suite |
| 23 | |
| 24 | session *r.Session |
| 25 | } |
| 26 | |
| 27 | func (suite *JoinsSuite) SetupTest() { |
| 28 | suite.T().Log("Setting up JoinsSuite") |
| 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_joins").Exec(suite.session) |
| 40 | err = r.DBCreate("db_joins").Exec(suite.session) |
| 41 | suite.Require().NoError(err) |
| 42 | err = r.DB("db_joins").Wait().Exec(suite.session) |
| 43 | suite.Require().NoError(err) |
| 44 | |
| 45 | r.DB("db_joins").TableDrop("messages").Exec(suite.session) |
| 46 | err = r.DB("db_joins").TableCreate("messages").Exec(suite.session) |
| 47 | suite.Require().NoError(err) |
| 48 | err = r.DB("db_joins").Table("messages").Wait().Exec(suite.session) |
| 49 | suite.Require().NoError(err) |
| 50 | r.DB("db_joins").TableDrop("otable_test_joins").Exec(suite.session) |
| 51 | err = r.DB("db_joins").TableCreate("otable_test_joins").Exec(suite.session) |
| 52 | suite.Require().NoError(err) |
| 53 | err = r.DB("db_joins").Table("otable_test_joins").Wait().Exec(suite.session) |
| 54 | suite.Require().NoError(err) |
| 55 | r.DB("db_joins").TableDrop("otable_test_joins2").Exec(suite.session) |
| 56 | err = r.DB("db_joins").TableCreate("otable_test_joins2").Exec(suite.session) |
| 57 | suite.Require().NoError(err) |
| 58 | err = r.DB("db_joins").Table("otable_test_joins2").Wait().Exec(suite.session) |
| 59 | suite.Require().NoError(err) |
| 60 | r.DB("db_joins").TableDrop("receivers").Exec(suite.session) |
| 61 | err = r.DB("db_joins").TableCreate("receivers").Exec(suite.session) |
| 62 | suite.Require().NoError(err) |
| 63 | err = r.DB("db_joins").Table("receivers").Wait().Exec(suite.session) |
| 64 | suite.Require().NoError(err) |
| 65 | r.DB("db_joins").TableDrop("senders").Exec(suite.session) |
| 66 | err = r.DB("db_joins").TableCreate("senders").Exec(suite.session) |
| 67 | suite.Require().NoError(err) |
| 68 | err = r.DB("db_joins").Table("senders").Wait().Exec(suite.session) |
| 69 | suite.Require().NoError(err) |
| 70 | r.DB("db_joins").TableDrop("table_test_joins").Exec(suite.session) |
| 71 | err = r.DB("db_joins").TableCreate("table_test_joins").Exec(suite.session) |
| 72 | suite.Require().NoError(err) |
| 73 | err = r.DB("db_joins").Table("table_test_joins").Wait().Exec(suite.session) |
| 74 | suite.Require().NoError(err) |
| 75 | r.DB("db_joins").TableDrop("table_test_joins2").Exec(suite.session) |
| 76 | err = r.DB("db_joins").TableCreate("table_test_joins2").Exec(suite.session) |
| 77 | suite.Require().NoError(err) |
| 78 | err = r.DB("db_joins").Table("table_test_joins2").Wait().Exec(suite.session) |
| 79 | suite.Require().NoError(err) |
| 80 | } |
| 81 | |
| 82 | func (suite *JoinsSuite) TearDownSuite() { |
| 83 | suite.T().Log("Tearing down JoinsSuite") |
| 84 | |
| 85 | if suite.session != nil { |
| 86 | r.DB("rethinkdb").Table("_debug_scratch").Delete().Exec(suite.session) |
| 87 | r.DB("db_joins").TableDrop("messages").Exec(suite.session) |
| 88 | r.DB("db_joins").TableDrop("otable_test_joins").Exec(suite.session) |
| 89 | r.DB("db_joins").TableDrop("otable_test_joins2").Exec(suite.session) |
| 90 | r.DB("db_joins").TableDrop("receivers").Exec(suite.session) |
| 91 | r.DB("db_joins").TableDrop("senders").Exec(suite.session) |
| 92 | r.DB("db_joins").TableDrop("table_test_joins").Exec(suite.session) |
| 93 | r.DB("db_joins").TableDrop("table_test_joins2").Exec(suite.session) |
| 94 | r.DBDrop("db_joins").Exec(suite.session) |
| 95 | |
| 96 | suite.session.Close() |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | func (suite *JoinsSuite) TestCases() { |
| 101 | suite.T().Log("Running JoinsSuite: Tests that manipulation data in tables") |
| 102 | |
| 103 | messages := r.DB("db_joins").Table("messages") |
| 104 | _ = messages // Prevent any noused variable errors |
| 105 | otable_test_joins := r.DB("db_joins").Table("otable_test_joins") |
| 106 | _ = otable_test_joins // Prevent any noused variable errors |
| 107 | otable_test_joins2 := r.DB("db_joins").Table("otable_test_joins2") |
| 108 | _ = otable_test_joins2 // Prevent any noused variable errors |
| 109 | receivers := r.DB("db_joins").Table("receivers") |
| 110 | _ = receivers // Prevent any noused variable errors |
| 111 | senders := r.DB("db_joins").Table("senders") |
| 112 | _ = senders // Prevent any noused variable errors |
| 113 | table_test_joins := r.DB("db_joins").Table("table_test_joins") |
| 114 | _ = table_test_joins // Prevent any noused variable errors |
| 115 | table_test_joins2 := r.DB("db_joins").Table("table_test_joins2") |
| 116 | _ = table_test_joins2 // Prevent any noused variable errors |
| 117 | |
| 118 | { |
| 119 | // joins.yaml line #7 |
| 120 | /* partial({'tables_created':1}) */ |
| 121 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_created": 1}) |
| 122 | /* r.db('test').table_create('test3', primary_key='foo') */ |
| 123 | |
| 124 | suite.T().Log("About to run line #7: r.DB('test').TableCreate('test3').OptArgs(r.TableCreateOpts{PrimaryKey: 'foo', })") |
| 125 | |
| 126 | runAndAssert(suite.Suite, expected_, r.DB("db_joins").TableCreate("test3").OptArgs(r.TableCreateOpts{PrimaryKey: "foo"}), suite.session, r.RunOpts{ |
| 127 | GeometryFormat: "raw", |
| 128 | GroupFormat: "map", |
| 129 | }) |
| 130 | suite.T().Log("Finished running line #7") |
| 131 | } |
| 132 | |
| 133 | // joins.yaml line #11 |
| 134 | // table_test_joins3 = r.db('test').table('test3') |
| 135 | suite.T().Log("Possibly executing: var table_test_joins3 r.Term = r.DB('test').Table('test3')") |
| 136 | |
| 137 | table_test_joins3 := r.DB("db_joins").Table("test3") |
| 138 | _ = table_test_joins3 // Prevent any noused variable errors |
| 139 | |
| 140 | { |
| 141 | // joins.yaml line #13 |
| 142 | /* partial({'errors':0, 'inserted':100}) */ |
| 143 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) |
| 144 | /* table_test_joins.insert(r.range(0, 100).map({'id':r.row, 'a':r.row % 4})) */ |
| 145 | |
| 146 | suite.T().Log("About to run line #13: table_test_joins.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'id': r.Row, 'a': r.Row.Mod(4), }))") |
| 147 | |
| 148 | runAndAssert(suite.Suite, expected_, table_test_joins.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"id": r.Row, "a": r.Row.Mod(4)})), suite.session, r.RunOpts{ |
| 149 | GeometryFormat: "raw", |
| 150 | GroupFormat: "map", |
| 151 | }) |
| 152 | suite.T().Log("Finished running line #13") |
| 153 | } |
| 154 | |
| 155 | { |
| 156 | // joins.yaml line #18 |
| 157 | /* partial({'errors':0, 'inserted':100}) */ |
| 158 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) |
| 159 | /* table_test_joins2.insert(r.range(0, 100).map({'id':r.row, 'b':r.row % 4})) */ |
| 160 | |
| 161 | suite.T().Log("About to run line #18: table_test_joins2.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'id': r.Row, 'b': r.Row.Mod(4), }))") |
| 162 | |
| 163 | runAndAssert(suite.Suite, expected_, table_test_joins2.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"id": r.Row, "b": r.Row.Mod(4)})), suite.session, r.RunOpts{ |
| 164 | GeometryFormat: "raw", |
| 165 | GroupFormat: "map", |
| 166 | }) |
| 167 | suite.T().Log("Finished running line #18") |
| 168 | } |
| 169 | |
| 170 | { |
| 171 | // joins.yaml line #23 |
| 172 | /* partial({'errors':0, 'inserted':100}) */ |
| 173 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"errors": 0, "inserted": 100}) |
| 174 | /* table_test_joins3.insert(r.range(0, 100).map({'foo':r.row, 'b':r.row % 4})) */ |
| 175 | |
| 176 | suite.T().Log("About to run line #23: table_test_joins3.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{'foo': r.Row, 'b': r.Row.Mod(4), }))") |
| 177 | |
| 178 | runAndAssert(suite.Suite, expected_, table_test_joins3.Insert(r.Range(0, 100).Map(map[interface{}]interface{}{"foo": r.Row, "b": r.Row.Mod(4)})), suite.session, r.RunOpts{ |
| 179 | GeometryFormat: "raw", |
| 180 | GroupFormat: "map", |
| 181 | }) |
| 182 | suite.T().Log("Finished running line #23") |
| 183 | } |
| 184 | |
| 185 | { |
| 186 | // joins.yaml line #28 |
| 187 | /* AnythingIsFine */ |
| 188 | var expected_ string = compare.AnythingIsFine |
| 189 | /* otable_test_joins.insert(r.range(1,100).map({'id': r.row, 'a': r.row})) */ |
| 190 | |
| 191 | suite.T().Log("About to run line #28: otable_test_joins.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{'id': r.Row, 'a': r.Row, }))") |
| 192 | |
| 193 | runAndAssert(suite.Suite, expected_, otable_test_joins.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{"id": r.Row, "a": r.Row})), suite.session, r.RunOpts{ |
| 194 | GeometryFormat: "raw", |
| 195 | GroupFormat: "map", |
| 196 | }) |
| 197 | suite.T().Log("Finished running line #28") |
| 198 | } |
| 199 | |
| 200 | { |
| 201 | // joins.yaml line #29 |
| 202 | /* AnythingIsFine */ |
| 203 | var expected_ string = compare.AnythingIsFine |
| 204 | /* otable_test_joins2.insert(r.range(1,100).map({'id': r.row, 'b': 2 * r.row})) */ |
| 205 | |
| 206 | suite.T().Log("About to run line #29: otable_test_joins2.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{'id': r.Row, 'b': r.Mul(2, r.Row), }))") |
| 207 | |
| 208 | runAndAssert(suite.Suite, expected_, otable_test_joins2.Insert(r.Range(1, 100).Map(map[interface{}]interface{}{"id": r.Row, "b": r.Mul(2, r.Row)})), suite.session, r.RunOpts{ |
| 209 | GeometryFormat: "raw", |
| 210 | GroupFormat: "map", |
| 211 | }) |
| 212 | suite.T().Log("Finished running line #29") |
| 213 | } |
| 214 | |
| 215 | // joins.yaml line #34 |
| 216 | // ij = table_test_joins.inner_join(table_test_joins2, lambda x,y:x['a'] == y['b']).zip() |
| 217 | suite.T().Log("Possibly executing: var ij r.Term = table_test_joins.InnerJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex('a').Eq(y.AtIndex('b'))}).Zip()") |
| 218 | |
| 219 | ij := table_test_joins.InnerJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex("a").Eq(y.AtIndex("b")) }).Zip() |
| 220 | _ = ij // Prevent any noused variable errors |
| 221 | |
| 222 | { |
| 223 | // joins.yaml line #37 |
| 224 | /* 2500 */ |
| 225 | var expected_ int = 2500 |
| 226 | /* ij.count() */ |
| 227 | |
| 228 | suite.T().Log("About to run line #37: ij.Count()") |
| 229 | |
| 230 | runAndAssert(suite.Suite, expected_, ij.Count(), suite.session, r.RunOpts{ |
| 231 | GeometryFormat: "raw", |
| 232 | GroupFormat: "map", |
| 233 | }) |
| 234 | suite.T().Log("Finished running line #37") |
| 235 | } |
| 236 | |
| 237 | { |
| 238 | // joins.yaml line #39 |
| 239 | /* 0 */ |
| 240 | var expected_ int = 0 |
| 241 | /* ij.filter(lambda row:row['a'] != row['b']).count() */ |
| 242 | |
| 243 | suite.T().Log("About to run line #39: ij.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Ne(row.AtIndex('b'))}).Count()") |
| 244 | |
| 245 | runAndAssert(suite.Suite, expected_, ij.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Ne(row.AtIndex("b")) }).Count(), suite.session, r.RunOpts{ |
| 246 | GeometryFormat: "raw", |
| 247 | GroupFormat: "map", |
| 248 | }) |
| 249 | suite.T().Log("Finished running line #39") |
| 250 | } |
| 251 | |
| 252 | // joins.yaml line #46 |
| 253 | // oj = table_test_joins.outer_join(table_test_joins2, lambda x,y:x['a'] == y['b']).zip() |
| 254 | suite.T().Log("Possibly executing: var oj r.Term = table_test_joins.OuterJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex('a').Eq(y.AtIndex('b'))}).Zip()") |
| 255 | |
| 256 | oj := table_test_joins.OuterJoin(table_test_joins2, func(x r.Term, y r.Term) interface{} { return x.AtIndex("a").Eq(y.AtIndex("b")) }).Zip() |
| 257 | _ = oj // Prevent any noused variable errors |
| 258 | |
| 259 | { |
| 260 | // joins.yaml line #49 |
| 261 | /* 2500 */ |
| 262 | var expected_ int = 2500 |
| 263 | /* oj.count() */ |
| 264 | |
| 265 | suite.T().Log("About to run line #49: oj.Count()") |
| 266 | |
| 267 | runAndAssert(suite.Suite, expected_, oj.Count(), suite.session, r.RunOpts{ |
| 268 | GeometryFormat: "raw", |
| 269 | GroupFormat: "map", |
| 270 | }) |
| 271 | suite.T().Log("Finished running line #49") |
| 272 | } |
| 273 | |
| 274 | { |
| 275 | // joins.yaml line #51 |
| 276 | /* 0 */ |
| 277 | var expected_ int = 0 |
| 278 | /* oj.filter(lambda row:row['a'] != row['b']).count() */ |
| 279 | |
| 280 | suite.T().Log("About to run line #51: oj.Filter(func(row r.Term) interface{} { return row.AtIndex('a').Ne(row.AtIndex('b'))}).Count()") |
| 281 | |
| 282 | runAndAssert(suite.Suite, expected_, oj.Filter(func(row r.Term) interface{} { return row.AtIndex("a").Ne(row.AtIndex("b")) }).Count(), suite.session, r.RunOpts{ |
| 283 | GeometryFormat: "raw", |
| 284 | GroupFormat: "map", |
| 285 | }) |
| 286 | suite.T().Log("Finished running line #51") |
| 287 | } |
| 288 | |
| 289 | // joins.yaml line #57 |
| 290 | // blah = otable_test_joins.order_by("id").eq_join(r.row['id'], otable_test_joins2, ordered=True).zip() |
| 291 | suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy('id').EqJoin(r.Row.AtIndex('id'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") |
| 292 | |
| 293 | blah := maybeRun(otable_test_joins.OrderBy("id").EqJoin(r.Row.AtIndex("id"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) |
| 294 | _ = blah // Prevent any noused variable errors |
| 295 | |
| 296 | // joins.yaml line #59 |
| 297 | // blah = otable_test_joins.order_by(r.desc("id")).eq_join(r.row['id'], otable_test_joins2, ordered=True).zip() |
| 298 | suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy(r.Desc('id')).EqJoin(r.Row.AtIndex('id'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") |
| 299 | |
| 300 | blah = maybeRun(otable_test_joins.OrderBy(r.Desc("id")).EqJoin(r.Row.AtIndex("id"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) |
| 301 | |
| 302 | // joins.yaml line #61 |
| 303 | // blah = otable_test_joins.order_by("id").eq_join(r.row['a'], otable_test_joins2, ordered=True).zip() |
| 304 | suite.T().Log("Possibly executing: var blah r.Term = otable_test_joins.OrderBy('id').EqJoin(r.Row.AtIndex('a'), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true, }).Zip()") |
| 305 | |
| 306 | blah = maybeRun(otable_test_joins.OrderBy("id").EqJoin(r.Row.AtIndex("a"), otable_test_joins2).OptArgs(r.EqJoinOpts{Ordered: true}).Zip(), suite.session, r.RunOpts{}) |
| 307 | |
| 308 | { |
| 309 | // joins.yaml line #65 |
| 310 | /* 100 */ |
| 311 | var expected_ int = 100 |
| 312 | /* table_test_joins.eq_join('a', table_test_joins2).zip().count() */ |
| 313 | |
| 314 | suite.T().Log("About to run line #65: table_test_joins.EqJoin('a', table_test_joins2).Zip().Count()") |
| 315 | |
| 316 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("a", table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ |
| 317 | GeometryFormat: "raw", |
| 318 | GroupFormat: "map", |
| 319 | }) |
| 320 | suite.T().Log("Finished running line #65") |
| 321 | } |
| 322 | |
| 323 | { |
| 324 | // joins.yaml line #68 |
| 325 | /* 0 */ |
| 326 | var expected_ int = 0 |
| 327 | /* table_test_joins.eq_join('fake', table_test_joins2).zip().count() */ |
| 328 | |
| 329 | suite.T().Log("About to run line #68: table_test_joins.EqJoin('fake', table_test_joins2).Zip().Count()") |
| 330 | |
| 331 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("fake", table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ |
| 332 | GeometryFormat: "raw", |
| 333 | GroupFormat: "map", |
| 334 | }) |
| 335 | suite.T().Log("Finished running line #68") |
| 336 | } |
| 337 | |
| 338 | { |
| 339 | // joins.yaml line #71 |
| 340 | /* 100 */ |
| 341 | var expected_ int = 100 |
| 342 | /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins2).zip().count() */ |
| 343 | |
| 344 | suite.T().Log("About to run line #71: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins2).Zip().Count()") |
| 345 | |
| 346 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ |
| 347 | GeometryFormat: "raw", |
| 348 | GroupFormat: "map", |
| 349 | }) |
| 350 | suite.T().Log("Finished running line #71") |
| 351 | } |
| 352 | |
| 353 | { |
| 354 | // joins.yaml line #76 |
| 355 | /* 0 */ |
| 356 | var expected_ int = 0 |
| 357 | /* table_test_joins.eq_join(lambda x:x['fake'], table_test_joins2).zip().count() */ |
| 358 | |
| 359 | suite.T().Log("About to run line #76: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('fake')}, table_test_joins2).Zip().Count()") |
| 360 | |
| 361 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("fake") }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ |
| 362 | GeometryFormat: "raw", |
| 363 | GroupFormat: "map", |
| 364 | }) |
| 365 | suite.T().Log("Finished running line #76") |
| 366 | } |
| 367 | |
| 368 | { |
| 369 | // joins.yaml line #81 |
| 370 | /* 0 */ |
| 371 | var expected_ int = 0 |
| 372 | /* table_test_joins.eq_join(lambda x:null, table_test_joins2).zip().count() */ |
| 373 | |
| 374 | suite.T().Log("About to run line #81: table_test_joins.EqJoin(func(x r.Term) interface{} { return nil}, table_test_joins2).Zip().Count()") |
| 375 | |
| 376 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return nil }, table_test_joins2).Zip().Count(), suite.session, r.RunOpts{ |
| 377 | GeometryFormat: "raw", |
| 378 | GroupFormat: "map", |
| 379 | }) |
| 380 | suite.T().Log("Finished running line #81") |
| 381 | } |
| 382 | |
| 383 | { |
| 384 | // joins.yaml line #86 |
| 385 | /* 100 */ |
| 386 | var expected_ int = 100 |
| 387 | /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins2).count() */ |
| 388 | |
| 389 | suite.T().Log("About to run line #86: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins2).Count()") |
| 390 | |
| 391 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins2).Count(), suite.session, r.RunOpts{ |
| 392 | GeometryFormat: "raw", |
| 393 | GroupFormat: "map", |
| 394 | }) |
| 395 | suite.T().Log("Finished running line #86") |
| 396 | } |
| 397 | |
| 398 | { |
| 399 | // joins.yaml line #92 |
| 400 | /* 100 */ |
| 401 | var expected_ int = 100 |
| 402 | /* table_test_joins.eq_join('a', table_test_joins3).zip().count() */ |
| 403 | |
| 404 | suite.T().Log("About to run line #92: table_test_joins.EqJoin('a', table_test_joins3).Zip().Count()") |
| 405 | |
| 406 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin("a", table_test_joins3).Zip().Count(), suite.session, r.RunOpts{ |
| 407 | GeometryFormat: "raw", |
| 408 | GroupFormat: "map", |
| 409 | }) |
| 410 | suite.T().Log("Finished running line #92") |
| 411 | } |
| 412 | |
| 413 | { |
| 414 | // joins.yaml line #95 |
| 415 | /* 100 */ |
| 416 | var expected_ int = 100 |
| 417 | /* table_test_joins.eq_join(lambda x:x['a'], table_test_joins3).count() */ |
| 418 | |
| 419 | suite.T().Log("About to run line #95: table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex('a')}, table_test_joins3).Count()") |
| 420 | |
| 421 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(func(x r.Term) interface{} { return x.AtIndex("a") }, table_test_joins3).Count(), suite.session, r.RunOpts{ |
| 422 | GeometryFormat: "raw", |
| 423 | GroupFormat: "map", |
| 424 | }) |
| 425 | suite.T().Log("Finished running line #95") |
| 426 | } |
| 427 | |
| 428 | { |
| 429 | // joins.yaml line #101 |
| 430 | /* 100 */ |
| 431 | var expected_ int = 100 |
| 432 | /* table_test_joins.eq_join(r.row['a'], table_test_joins2).count() */ |
| 433 | |
| 434 | suite.T().Log("About to run line #101: table_test_joins.EqJoin(r.Row.AtIndex('a'), table_test_joins2).Count()") |
| 435 | |
| 436 | runAndAssert(suite.Suite, expected_, table_test_joins.EqJoin(r.Row.AtIndex("a"), table_test_joins2).Count(), suite.session, r.RunOpts{ |
| 437 | GeometryFormat: "raw", |
| 438 | GroupFormat: "map", |
| 439 | }) |
| 440 | suite.T().Log("Finished running line #101") |
| 441 | } |
| 442 | |
| 443 | // joins.yaml line #106 |
| 444 | // left = r.expr([{'a':1},{'a':2},{'a':3}]) |
| 445 | suite.T().Log("Possibly executing: var left r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'a': 1, }, map[interface{}]interface{}{'a': 2, }, map[interface{}]interface{}{'a': 3, }})") |
| 446 | |
| 447 | left := r.Expr([]interface{}{map[interface{}]interface{}{"a": 1}, map[interface{}]interface{}{"a": 2}, map[interface{}]interface{}{"a": 3}}) |
| 448 | _ = left // Prevent any noused variable errors |
| 449 | |
| 450 | // joins.yaml line #107 |
| 451 | // right = r.expr([{'b':2},{'b':3}]) |
| 452 | suite.T().Log("Possibly executing: var right r.Term = r.Expr([]interface{}{map[interface{}]interface{}{'b': 2, }, map[interface{}]interface{}{'b': 3, }})") |
| 453 | |
| 454 | right := r.Expr([]interface{}{map[interface{}]interface{}{"b": 2}, map[interface{}]interface{}{"b": 3}}) |
| 455 | _ = right // Prevent any noused variable errors |
| 456 | |
| 457 | { |
| 458 | // joins.yaml line #109 |
| 459 | /* [{'a':2,'b':2},{'a':3,'b':3}] */ |
| 460 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 2, "b": 2}, map[interface{}]interface{}{"a": 3, "b": 3}} |
| 461 | /* left.inner_join(right, lambda l, r:l['a'] == r['b']).zip() */ |
| 462 | |
| 463 | suite.T().Log("About to run line #109: left.InnerJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex('a').Eq(r.AtIndex('b'))}).Zip()") |
| 464 | |
| 465 | runAndAssert(suite.Suite, expected_, left.InnerJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex("a").Eq(r.AtIndex("b")) }).Zip(), suite.session, r.RunOpts{ |
| 466 | GeometryFormat: "raw", |
| 467 | GroupFormat: "map", |
| 468 | }) |
| 469 | suite.T().Log("Finished running line #109") |
| 470 | } |
| 471 | |
| 472 | { |
| 473 | // joins.yaml line #115 |
| 474 | /* [{'a':1},{'a':2,'b':2},{'a':3,'b':3}] */ |
| 475 | var expected_ []interface{} = []interface{}{map[interface{}]interface{}{"a": 1}, map[interface{}]interface{}{"a": 2, "b": 2}, map[interface{}]interface{}{"a": 3, "b": 3}} |
| 476 | /* left.outer_join(right, lambda l, r:l['a'] == r['b']).zip() */ |
| 477 | |
| 478 | suite.T().Log("About to run line #115: left.OuterJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex('a').Eq(r.AtIndex('b'))}).Zip()") |
| 479 | |
| 480 | runAndAssert(suite.Suite, expected_, left.OuterJoin(right, func(l r.Term, r r.Term) interface{} { return l.AtIndex("a").Eq(r.AtIndex("b")) }).Zip(), suite.session, r.RunOpts{ |
| 481 | GeometryFormat: "raw", |
| 482 | GroupFormat: "map", |
| 483 | }) |
| 484 | suite.T().Log("Finished running line #115") |
| 485 | } |
| 486 | |
| 487 | { |
| 488 | // joins.yaml line #132 |
| 489 | /* partial({'tables_dropped':1}) */ |
| 490 | var expected_ compare.Expected = compare.PartialMatch(map[interface{}]interface{}{"tables_dropped": 1}) |
| 491 | /* r.db('test').table_drop('test3') */ |
| 492 | |
| 493 | suite.T().Log("About to run line #132: r.DB('test').TableDrop('test3')") |
| 494 | |
| 495 | runAndAssert(suite.Suite, expected_, r.DB("db_joins").TableDrop("test3"), suite.session, r.RunOpts{ |
| 496 | GeometryFormat: "raw", |
| 497 | GroupFormat: "map", |
| 498 | }) |
| 499 | suite.T().Log("Finished running line #132") |
| 500 | } |
| 501 | } |