diff --git a/packages/realm/src/PropertyMap.ts b/packages/realm/src/PropertyMap.ts index dcca82d642a..4a113a9e160 100644 --- a/packages/realm/src/PropertyMap.ts +++ b/packages/realm/src/PropertyMap.ts @@ -31,7 +31,10 @@ export class PropertyMap { private objectSchemaName: string | null = null; private initialized = false; private mapping: Record = {}; - private nameByColumnKey: Map = new Map(); + /** + * Note: Cannot key by the binding.ColKey directly, as this is `Long` on JSC (which does not compare equal) + */ + private nameByColumnKeyString: Map = new Map(); private _names: string[] = []; public initialize(objectSchema: BindingObjectSchema, defaults: Record, options: HelperOptions) { @@ -51,7 +54,7 @@ export class PropertyMap { return [propertyName, helpers]; }), ); - this.nameByColumnKey = new Map(properties.map((p) => [p.columnKey, p.publicName || p.name])); + this.nameByColumnKeyString = new Map(properties.map((p) => [p.columnKey.toString(), p.publicName || p.name])); this._names = properties.map((p) => p.publicName || p.name); this.initialized = true; } @@ -70,7 +73,7 @@ export class PropertyMap { public getName = (columnKey: binding.ColKey): keyof T => { if (this.initialized) { - return this.nameByColumnKey.get(columnKey) as keyof T; + return this.nameByColumnKeyString.get(columnKey.toString()) as keyof T; } else { throw new UninitializedPropertyMapError(); }