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

Avoid BigInt literals as JSC/Android doesn't support it #6289

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixed
* When mapTo is used on a property of type List, an error like `Property 'test_list' does not exist on 'Task' objects` occurs when trying to access the property. ([#6268](https://github.com/realm/realm-js/issues/6268), since v12.0.0)
* Fixed bug where apps running under JavaScriptCore on Android will terminate with the error message `No identifiers allowed directly after numeric literal`. ([#6194](https://github.com/realm/realm-js/issues/6194), since v12.2.0)

### Compatibility
* React Native >= v0.71.4
Expand Down
4 changes: 2 additions & 2 deletions packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@
* @since 0.11.0
*/
public static schemaVersion(path: string, encryptionKey?: ArrayBuffer | ArrayBufferView): number {
const notFound = 18446744073709551615n; // std::numeric_limit<uint64_t>::max() = 0xffffffffffffffff
const notFound = "18446744073709551615"; // std::numeric_limit<uint64_t>::max() = 0xffffffffffffffff as string
const config: Configuration = { path };
const absolutePath = Realm.determinePath(config);
const schemaVersion = binding.Realm.getSchemaVersion({
path: absolutePath,
encryptionKey: Realm.determineEncryptionKey(encryptionKey),
});
// no easy way to compare uint64_t in TypeScript
return notFound.toString() === schemaVersion.toString() ? -1 : binding.Int64.intToNum(schemaVersion);
return notFound === schemaVersion.toString() ? -1 : binding.Int64.intToNum(schemaVersion);
}

/**
Expand Down Expand Up @@ -906,7 +906,7 @@
* Deletes the provided Realm object, or each one inside the provided collection.
* @param subject - The Realm object to delete, or a collection containing multiple Realm objects to delete.
*/
delete(subject: AnyRealmObject | AnyRealmObject[] | AnyList | AnyResults | any): void {

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

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
assert.inTransaction(this, "Can only delete objects within a transaction.");
assert.object(subject, "subject");
if (subject instanceof RealmObject) {
Expand Down Expand Up @@ -939,7 +939,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 942 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 @@ -1102,7 +1102,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 1105 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 @@ -1146,7 +1146,7 @@
}

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

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

View workflow job for this annotation

GitHub Actions / Lint

The type 'beginTransaction' 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