From 058f1a5b1d4fe9a46014c4d24d322d55628900b4 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Fri, 9 Oct 2020 15:32:29 +0200 Subject: [PATCH 1/2] Porting https://github.com/realm/realm-js/pull/3322 --- CHANGELOG.md | 1 + src/js_realm.hpp | 1 + tests/js/realm-tests.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf0fe71aca..6fa352576c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ x.x.x Release notes (yyyy-MM-dd) ### Internal * Changed CI to abort if changes are exclusively made to the /packages directory. ([#3298](https://github.com/realm/realm-js/pull/3298)) & ([#3307](https://github.com/realm/realm-js/pull/3307)) +* Porting https://github.com/realm/realm-js/pull/3322. 10.0.0-rc.1 Release notes (2020-10-1) ============================================================= diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 67678082d3..29b05254e5 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -643,6 +643,7 @@ bool RealmClass::get_realm_config(ContextType ctx, size_t argc, const ValueTy } } + config.cache = true; config.path = normalize_realm_path(config.path); ensure_directory_exists_for_file(config.path); return schema_updated; diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 18309759b7..2030578b8a 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -1538,8 +1538,9 @@ module.exports = { testManualCompactMultipleInstances: function() { const realm1 = new Realm({schema: [schemas.StringOnly]}); const realm2 = new Realm({schema: [schemas.StringOnly]}); + // realm1 and realm2 are the same Realm instance realm2.objects('StringOnlyObject'); - TestCase.assertFalse(realm1.compact()); + TestCase.assertTrue(realm1.compact()); }, testRealmDeleteFileDefaultConfigPath: function() { From 5c03fb292c787b53acae818c8336374ebfc9a711 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 12 Oct 2020 11:42:00 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa352576c..fa8ce41e6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ x.x.x Release notes (yyyy-MM-dd) * Fixed a bug where an integer could prematurely be converted & returned as a `Long` instead of a `number`. ([#3205](https://github.com/realm/realm-js/pull/3205), since v10.0.0-beta.1) * TS declaration for `isLoggedIn` added to `User`. ([#3294](https://github.com/realm/realm-js/pull/3294)) * Fixed error `Attempted import error: 'invalidateCache' is not exported from './util' (imported as 'util').` ([#3314](https://github.com/realm/realm-js/issues/3314)) +* Fixed a bug preventing caching of Realm instances. In certain cases, the Realm file would grow without any new objects added. ### Compatibility * MongoDB Realm Cloud. @@ -21,7 +22,6 @@ x.x.x Release notes (yyyy-MM-dd) ### Internal * Changed CI to abort if changes are exclusively made to the /packages directory. ([#3298](https://github.com/realm/realm-js/pull/3298)) & ([#3307](https://github.com/realm/realm-js/pull/3307)) -* Porting https://github.com/realm/realm-js/pull/3322. 10.0.0-rc.1 Release notes (2020-10-1) =============================================================