From 9efb07f39240d71ab8ca758d995b78c0d9648869 Mon Sep 17 00:00:00 2001 From: Peter van Gulik Date: Mon, 25 Sep 2023 11:14:31 +0200 Subject: [PATCH] fix: `RecordFactory.useRecordProxy` static is incorrectly marked as readonly --- packages/salesforce/src/queryRecordFactory.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/salesforce/src/queryRecordFactory.ts b/packages/salesforce/src/queryRecordFactory.ts index 04b87212..4039d2d5 100644 --- a/packages/salesforce/src/queryRecordFactory.ts +++ b/packages/salesforce/src/queryRecordFactory.ts @@ -25,11 +25,16 @@ export class RecordFactory { private static readonly fieldMapKey = Symbol('fields'); /** - * Create records using a proxy to intercept property access and transform the property name to the correct casing. + * Create records using a JS Proxy to intercept property access and transform the property name to the correct casing. + * When enabled the property access is case insensitive and upon each property access the property + * name is normalized and checked against all normalized field names in the current record. This can be slow due to the + * the multiple string comparisons that need to be executed. * - * If false uses the defineProperty approach to transform the property names which is by design case sensitive. + * When `false` the RecordFactory will use `Object.defineProperty` to transform the property + * names which causes the normalized property names to always be case sensitive but avoids + * the disadvantages of using a Proxy. */ - public static readonly useRecordProxy = false; + public static useRecordProxy = false; private readonly schemaService: SalesforceSchemaService; @@ -155,10 +160,6 @@ export class RecordFactory { fieldMap = RecordFactory.generateNormalizedFieldMap(Object.keys(target)); } - if (String(name).toLowerCase() === 'id' && target['']) { - return 'Id'; - } - return fieldMap.get(String(name).toLowerCase()) ?? fieldMap.get(normalizeSalesforceName(String(name)).toLowerCase()) ?? name;