@@ -89,6 +89,7 @@ std::pair<SharedRealm, std::exception_ptr> async_open_realm(const Realm::Config&
8989std::vector<ObjectSchema> get_schema_v0 ()
9090{
9191 return {
92+ {" Embedded" , ObjectSchema::ObjectType::Embedded, {{" str_field" , PropertyType::String}}},
9293 {" TopLevel" ,
9394 {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
9495 {" queryable_str_field" , PropertyType::String | PropertyType::Nullable},
@@ -101,7 +102,10 @@ std::vector<ObjectSchema> get_schema_v0()
101102 {" queryable_int_field" , PropertyType::Int | PropertyType::Nullable},
102103 {" non_queryable_field" , PropertyType::String | PropertyType::Nullable}}},
103104 {" TopLevel3" ,
104- {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }}, {" queryable_int_field" , PropertyType::Int}}},
105+ {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
106+ {" queryable_int_field" , PropertyType::Int},
107+ {" link" , PropertyType::Object | PropertyType::Nullable, " TopLevel" },
108+ {" embedded_link" , PropertyType::Object | PropertyType::Nullable, " Embedded" }}},
105109 };
106110}
107111
@@ -135,12 +139,16 @@ auto get_subscription_initializer_callback_for_schema_v0()
135139std::vector<ObjectSchema> get_schema_v1 ()
136140{
137141 return {
142+ {" Embedded" , ObjectSchema::ObjectType::Embedded, {{" str_field" , PropertyType::String}}},
138143 {" TopLevel" ,
139144 {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
140145 {" queryable_int_field" , PropertyType::Int | PropertyType::Nullable},
141146 {" non_queryable_field" , PropertyType::String},
142147 {" non_queryable_field2" , PropertyType::String | PropertyType::Nullable}}},
143- {" TopLevel3" , {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }}}},
148+ {" TopLevel3" ,
149+ {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
150+ {" link" , PropertyType::Object | PropertyType::Nullable, " TopLevel" },
151+ {" embedded_link" , PropertyType::Object | PropertyType::Nullable, " Embedded" }}},
144152 };
145153}
146154
@@ -165,12 +173,16 @@ auto get_subscription_initializer_callback_for_schema_v1()
165173std::vector<ObjectSchema> get_schema_v2 ()
166174{
167175 return {
176+ {" Embedded" , ObjectSchema::ObjectType::Embedded, {{" str_field" , PropertyType::String}}},
168177 {" TopLevel" ,
169178 {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
170179 {" queryable_int_field" , PropertyType::Int},
171180 {" non_queryable_field" , PropertyType::String},
172181 {" non_queryable_field2" , PropertyType::String | PropertyType::Nullable}}},
173- {" TopLevel3" , {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }}}},
182+ {" TopLevel3" ,
183+ {{" _id" , PropertyType::ObjectId, Property::IsPrimary{true }},
184+ {" link" , PropertyType::Object | PropertyType::Nullable, " TopLevel" },
185+ {" embedded_link" , PropertyType::Object | PropertyType::Nullable, " Embedded" }}},
174186 };
175187}
176188
@@ -262,7 +274,7 @@ TEST_CASE("Sync schema migrations don't work with sync open", "[sync][flx][flx s
262274
263275 SECTION (" Breaking change detected by client" ) {
264276 // Make field 'non_queryable_field2' of table 'TopLevel' optional.
265- schema_v1[0 ].persisted_properties .back () = {" non_queryable_field2" ,
277+ schema_v1[1 ].persisted_properties .back () = {" non_queryable_field2" ,
266278 PropertyType::String | PropertyType::Nullable};
267279 config.schema = schema_v1;
268280 create_schema (app_session, *config.schema , config.schema_version );
@@ -272,8 +284,8 @@ TEST_CASE("Sync schema migrations don't work with sync open", "[sync][flx][flx s
272284 }
273285
274286 SECTION (" Breaking change detected by server" ) {
275- // Remove table 'TopLevel3 '.
276- schema_v1.pop_back ( );
287+ // Remove table 'TopLevel2 '.
288+ schema_v1.erase (schema_v1. begin () + 2 );
277289 config.schema = schema_v1;
278290 create_schema (app_session, *config.schema , config.schema_version );
279291
@@ -294,8 +306,8 @@ TEST_CASE("Sync schema migrations don't work with sync open", "[sync][flx][flx s
294306 wait_for_download (*realm);
295307 wait_for_upload (*realm);
296308
297- auto table = realm->read_group ().get_table (" class_TopLevel3 " );
298- // Migration did not succeed because table 'TopLevel3 ' still exists (but there is no error).
309+ auto table = realm->read_group ().get_table (" class_TopLevel2 " );
310+ // Migration did not succeed because table 'TopLevel2 ' still exists (but there is no error).
299311 CHECK (table);
300312 check_realm_schema (config.path , schema_v0, 1 );
301313 }
0 commit comments