Skip to content

Commit

Permalink
fix: RecordFactory.useRecordProxy static is incorrectly marked as r…
Browse files Browse the repository at this point in the history
…eadonly
  • Loading branch information
Codeneos committed Sep 25, 2023
1 parent afb2d45 commit 9efb07f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/salesforce/src/queryRecordFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9efb07f

Please sign in to comment.