Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RJS-2846: Fix path configuration when using sync #6753

Merged
merged 12 commits into from
Jun 25, 2024
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* None

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
* None
* `path` option in the Realm configuration not being set when using a synced Realm. ([#6753](https://github.com/realm/realm-js/pull/6753), since v12.8.0)

### Compatibility
* React Native >= v0.71.4
Expand Down
9 changes: 9 additions & 0 deletions integration-tests/tests/src/tests/sync/flexible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ describe("Flexible sync", function () {
closeRealm(realm2);
});

it("sets the correct path from the configuration", async function () {
gagik marked this conversation as resolved.
Show resolved Hide resolved
gagik marked this conversation as resolved.
Show resolved Hide resolved
const realm = await Realm.open({
path: "custom_path.realm",
...getSuccessConfig(this.user, {}),
});

expect(realm.path).to.contain("custom_path.realm");
gagik marked this conversation as resolved.
Show resolved Hide resolved
});

it("does not update the subscriptions on second open if rerunOnOpen is false", async function (this: RealmContext) {
const realm = await testSuccess(this.user, { rerunOnOpen: false }, false);
if (!realm) throw new Error("Valid realm was not returned from testSuccess");
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
return Realm.normalizePath(config.path);
} else {
const bindingSyncConfig = toBindingSyncConfig(config.sync);
return config.sync.user.internal.pathForRealm(bindingSyncConfig, undefined);
return config.sync.user.internal.pathForRealm(bindingSyncConfig, config.path);
}
} else {
return Realm.normalizePath(config.path);
Expand Down Expand Up @@ -839,7 +839,7 @@

/**
* Deletes a Realm model, including all of its objects.
* If called outside a migration function, {@link schema} and {@link schemaVersion} are updated.

Check warning on line 842 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'schemaVersion' is undefined
* @param name - The model name.
*/
deleteModel(name: string): void {
Expand Down Expand Up @@ -1001,7 +1001,7 @@
* Remove the listener {@link callback} for the specified event {@link eventName}.
* @param eventName - The event name.
* @param callback - Function that was previously added as a listener for this event through the {@link addListener} method.
* @throws an {@link Error} If an invalid event {@link eventName} is supplied, if Realm is closed or if {@link callback} is not a function.

Check warning on line 1004 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'addListener' is undefined
*/
removeListener(eventName: RealmEventName, callback: RealmListenerCallback): void {
assert.open(this);
Expand Down Expand Up @@ -1045,7 +1045,7 @@
}

/**
* Synchronously call the provided {@link callback} inside a write transaction. If an exception happens inside a transaction,

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'beginTransaction' is undefined

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'commitTransaction' is undefined

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'cancelTransaction' is undefined

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'commitTransaction' is undefined

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'write' is undefined

Check warning on line 1048 in packages/realm/src/Realm.ts

View workflow job for this annotation

GitHub Actions / Lint

The type 'write' is undefined
* you’ll lose the changes in that transaction, but the Realm itself won’t be affected (or corrupted).
* More precisely, {@link beginTransaction} and {@link commitTransaction} will be called
* automatically. If any exception is thrown during the transaction {@link cancelTransaction} will
Expand Down
Loading