From 0fb0967ee089801d482ba758a23304df1f9decc1 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Tue, 7 Jun 2022 11:16:55 +0200 Subject: [PATCH] Realm.Configuration.sync can be a boolean (#4616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Realm.Configuration.sync can be a boolean Co-authored-by: Kræn Hansen --- CHANGELOG.md | 1 + src/js_realm.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f27656193..b1163e5e6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ x.x.x Release notes (yyyy-MM-dd) * * * +* Fixed a bug preventing opening a synced Realm as a local Realm. (since v10.18.0) 10.19.0 Release notes (2022-6-2) ============================================================= diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 4da97f02f5..79fa832005 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -838,7 +838,7 @@ void RealmClass::handle_initial_subscriptions(ContextType ctx, size_t argc, c ObjectType config_object = Value::to_object(ctx, config_value); ValueType sync_value = Object::get_property(ctx, config_object, "sync"); - if (Value::is_undefined(ctx, sync_value)) { + if (!Value::is_object(ctx, sync_value)) { return; } ObjectType sync_object = Value::validated_to_object(ctx, sync_value); @@ -1564,8 +1564,9 @@ realm::Realm::Config RealmClass::write_copy_to_helper(ContextType ctx, Object // validate 5) // check whether a sync config exists -- it is optional ValueType syncConfigValue = Object::get_property(ctx, output_config, "sync"); - if (!Value::is_undefined(ctx, syncConfigValue) && !Value::is_object(ctx, syncConfigValue)) { - throw std::invalid_argument("'sync' property must be an object"); + if (!Value::is_undefined(ctx, syncConfigValue) && !Value::is_object(ctx, syncConfigValue) && + !Value::is_boolean(ctx, syncConfigValue)) { + throw std::invalid_argument("if set, 'sync' property must be an object or a boolean"); }