@@ -330,10 +330,13 @@ columns or queries involved
330
330
*/
331
331
332
332
333
- TEST (Query_NextGen_StringConditions)
333
+ TEST_TYPES (Query_NextGen_StringConditions, std::true_type, std::false_type )
334
334
{
335
- Group group;
336
- TableRef table1 = group.add_table (" table1" );
335
+ SHARED_GROUP_TEST_PATH (path);
336
+
337
+ auto db = DB::create (make_in_realm_history (), path);
338
+ auto wt = db->start_write ();
339
+ TableRef table1 = wt->add_table (" table1" );
337
340
auto col_str1 = table1->add_column (type_String, " str1" );
338
341
auto col_str2 = table1->add_column (type_String, " str2" );
339
342
@@ -342,6 +345,11 @@ TEST(Query_NextGen_StringConditions)
342
345
table1->create_object ().set_all (" !" , " x" ).get_key ();
343
346
ObjKey key_1_2 = table1->create_object ().set_all (" bar" , " r" ).get_key ();
344
347
348
+ if (TEST_TYPE::value) {
349
+ wt->commit_and_continue_as_read ();
350
+ wt->promote_to_write ();
351
+ }
352
+
345
353
ObjKey m;
346
354
// Equal
347
355
m = table1->column <String>(col_str1).equal (" bar" , false ).find ();
@@ -433,7 +441,7 @@ TEST(Query_NextGen_StringConditions)
433
441
CHECK_EQUAL (m, null_key);
434
442
435
443
// Test various compare operations with null
436
- TableRef table2 = group. add_table (" table2" );
444
+ TableRef table2 = wt-> add_table (" table2" );
437
445
auto col_str3 = table2->add_column (type_String, " str3" , true );
438
446
439
447
ObjKey key_2_0 = table2->create_object ().set (col_str3, " foo" ).get_key ();
@@ -442,6 +450,11 @@ TEST(Query_NextGen_StringConditions)
442
450
ObjKey key_2_3 = table2->create_object ().set (col_str3, " bar" ).get_key ();
443
451
ObjKey key_2_4 = table2->create_object ().set (col_str3, " " ).get_key ();
444
452
453
+ if (TEST_TYPE::value) {
454
+ wt->commit_and_continue_as_read ();
455
+ wt->promote_to_write ();
456
+ }
457
+
445
458
size_t cnt;
446
459
cnt = table2->column <String>(col_str3).contains (StringData (" " )).count ();
447
460
CHECK_EQUAL (cnt, 4 );
@@ -522,6 +535,12 @@ TEST(Query_NextGen_StringConditions)
522
535
}
523
536
};
524
537
538
+ // not equal
539
+ check_results ((table2->column <String>(col_str3) != StringData (" " )), {StringData (), " foo" , " bar" , " !" });
540
+ check_results ((table2->column <String>(col_str3) != StringData ()), {" " , " foo" , " bar" , " !" });
541
+ check_results ((table2->column <String>(col_str3) != StringData (" foo" )), {StringData (), " " , " bar" , " !" });
542
+ check_results ((table2->column <String>(col_str3) != StringData (" barr" )), {StringData (), " " , " foo" , " bar" , " !" });
543
+
525
544
// greater
526
545
check_results ((table2->column <String>(col_str3) > StringData (" " )), {" foo" , " bar" , " !" });
527
546
check_results ((table2->column <String>(col_str3) > StringData (" b" )), {" foo" , " bar" });
@@ -553,7 +572,7 @@ TEST(Query_NextGen_StringConditions)
553
572
check_results ((table2->column <String>(col_str3) <= StringData (" barrrr" )), {" bar" , " " , " !" , StringData ()});
554
573
check_results ((table2->column <String>(col_str3) <= StringData (" z" )), {" foo" , " bar" , " " , " !" , StringData ()});
555
574
556
- TableRef table3 = group. add_table (StringData (" table3" ));
575
+ TableRef table3 = wt-> add_table (StringData (" table3" ));
557
576
auto col_link1 = table3->add_column (*table2, " link1" );
558
577
559
578
table3->create_object ().set (col_link1, key_2_0);
@@ -562,6 +581,11 @@ TEST(Query_NextGen_StringConditions)
562
581
table3->create_object ().set (col_link1, key_2_3);
563
582
table3->create_object ().set (col_link1, key_2_4);
564
583
584
+ if (TEST_TYPE::value) {
585
+ wt->commit_and_continue_as_read ();
586
+ wt->promote_to_write ();
587
+ }
588
+
565
589
cnt = table3->link (col_link1).column <String>(col_str3).contains (StringData (" " )).count ();
566
590
CHECK_EQUAL (cnt, 4 );
567
591
@@ -638,8 +662,14 @@ TEST(Query_NextGen_StringConditions)
638
662
" This is a long search string that does not contain the word being searched for!, "
639
663
" This is a long search string that does not contain the word being searched for!, "
640
664
" needle" ;
665
+
641
666
table2->create_object ().set (col_str3, long_string).get_key ();
642
667
668
+ if (TEST_TYPE::value) {
669
+ wt->commit_and_continue_as_read ();
670
+ wt->promote_to_write ();
671
+ }
672
+
643
673
cnt = table2->column <String>(col_str3).contains (search_1, false ).count ();
644
674
CHECK_EQUAL (cnt, 1 );
645
675
0 commit comments