Skip to content

Commit e76f494

Browse files
authored
Merge pull request #7003 from realm/tg/asymmetric-object-list
Allow collections of non-embedded objects in asymmetric objects
2 parents 035f66c + 8278d2b commit e76f494

File tree

11 files changed

+301
-124
lines changed

11 files changed

+301
-124
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Enhancements
44
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
5-
* None.
5+
* Allow collections of non-embedded links in asymmetric objects. ([PR #7003](https://github.com/realm/realm-core/pull/7003))
66

77
### Fixed
88
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)

src/realm/table.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,6 @@ ColKey Table::add_column_list(Table& target, StringData name)
459459
Group* target_group = target.get_parent_group();
460460
REALM_ASSERT_RELEASE(origin_group && target_group);
461461
REALM_ASSERT_RELEASE(origin_group == target_group);
462-
// Only links to embedded objects are allowed.
463-
if (is_asymmetric() && !target.is_embedded()) {
464-
throw IllegalOperation("List of objects not supported in asymmetric table");
465-
}
466462
// Incoming links from an asymmetric table are not allowed.
467463
if (target.is_asymmetric()) {
468464
throw IllegalOperation("List of ephemeral objects not supported");
@@ -486,10 +482,6 @@ ColKey Table::add_column_set(Table& target, StringData name)
486482
REALM_ASSERT_RELEASE(origin_group == target_group);
487483
if (target.is_embedded())
488484
throw IllegalOperation("Set of embedded objects not supported");
489-
// Outgoing links from an asymmetric table are not allowed.
490-
if (is_asymmetric()) {
491-
throw IllegalOperation("Set of objects not supported in asymmetric table");
492-
}
493485
// Incoming links from an asymmetric table are not allowed.
494486
if (target.is_asymmetric()) {
495487
throw IllegalOperation("Set of ephemeral objects not supported");
@@ -533,10 +525,6 @@ ColKey Table::add_column_dictionary(Table& target, StringData name, DataType key
533525
Group* target_group = target.get_parent_group();
534526
REALM_ASSERT_RELEASE(origin_group && target_group);
535527
REALM_ASSERT_RELEASE(origin_group == target_group);
536-
// Only links to embedded objects are allowed.
537-
if (is_asymmetric() && !target.is_embedded()) {
538-
throw IllegalOperation("Dictionary of objects not supported in asymmetric table");
539-
}
540528
// Incoming links from an asymmetric table are not allowed.
541529
if (target.is_asymmetric()) {
542530
throw IllegalOperation("Dictionary of ephemeral objects not supported");

test/object-store/audit.cpp

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -167,51 +167,28 @@ void sort_events(std::vector<AuditEvent>& events)
167167
static std::vector<AuditEvent> get_audit_events_from_baas(TestAppSession& session, SyncUser& user,
168168
size_t expected_count)
169169
{
170-
auto& app_session = session.app_session();
171-
app::MongoClient remote_client = user.mongo_client("BackingDB");
172-
app::MongoDatabase db = remote_client.db(app_session.config.mongo_dbname);
173-
app::MongoCollection collection = db["AuditEvent"];
174-
std::vector<AuditEvent> events;
175170
static const std::set<std::string> nonmetadata_fields = {"activity", "event", "data", "realm_id"};
176171

177-
timed_wait_for(
178-
[&] {
179-
uint64_t count = 0;
180-
collection.count({}, [&](uint64_t c, util::Optional<app::AppError> error) {
181-
REQUIRE(!error);
182-
count = c;
183-
});
184-
if (count < expected_count) {
185-
millisleep(500); // slow down the number of retries
186-
return false;
187-
}
188-
return true;
189-
},
190-
std::chrono::minutes(5));
191-
192-
collection.find({}, {},
193-
[&](util::Optional<std::vector<bson::Bson>>&& result, util::Optional<app::AppError> error) {
194-
REQUIRE(!error);
195-
REQUIRE(result->size() >= expected_count);
196-
events.reserve(result->size());
197-
for (auto bson : *result) {
198-
auto doc = static_cast<const bson::BsonDocument&>(bson).entries();
199-
AuditEvent event;
200-
event.activity = static_cast<std::string>(doc["activity"]);
201-
event.timestamp = static_cast<Timestamp>(doc["timestamp"]);
202-
if (auto it = doc.find("event"); it != doc.end() && it->second != bson::Bson()) {
203-
event.event = static_cast<std::string>(it->second);
204-
}
205-
if (auto it = doc.find("data"); it != doc.end() && it->second != bson::Bson()) {
206-
event.data = json::parse(static_cast<std::string>(it->second));
207-
}
208-
for (auto& [key, value] : doc) {
209-
if (value.type() == bson::Bson::Type::String && !nonmetadata_fields.count(key))
210-
event.metadata.insert({key, static_cast<std::string>(value)});
211-
}
212-
events.push_back(event);
213-
}
214-
});
172+
auto documents = session.get_documents(user, "AuditEvent", expected_count);
173+
std::vector<AuditEvent> events;
174+
events.reserve(documents.size());
175+
for (auto document : documents) {
176+
auto doc = document.entries();
177+
AuditEvent event;
178+
event.activity = static_cast<std::string>(doc["activity"]);
179+
event.timestamp = static_cast<Timestamp>(doc["timestamp"]);
180+
if (auto it = doc.find("event"); it != doc.end() && it->second != bson::Bson()) {
181+
event.event = static_cast<std::string>(it->second);
182+
}
183+
if (auto it = doc.find("data"); it != doc.end() && it->second != bson::Bson()) {
184+
event.data = json::parse(static_cast<std::string>(it->second));
185+
}
186+
for (auto& [key, value] : doc) {
187+
if (value.type() == bson::Bson::Type::String && !nonmetadata_fields.count(key))
188+
event.metadata.insert({key, static_cast<std::string>(value)});
189+
}
190+
events.push_back(event);
191+
}
215192
sort_events(events);
216193
return events;
217194
}

test/object-store/realm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3561,7 +3561,7 @@ TEST_CASE("SharedRealm: SchemaChangedFunction") {
35613561
size_t schema_changed_called = 0;
35623562
Schema changed_fixed_schema;
35633563
TestFile config;
3564-
auto dynamic_config = config;
3564+
RealmConfig dynamic_config = config;
35653565

35663566
config.schema = Schema{{"object1",
35673567
{

0 commit comments

Comments
 (0)