Skip to content

Commit 9059150

Browse files
authored
fix(query-result-proxy): add object methods like hasOwnProperty (#1442)
fix(query-result-proxy): add object methods like hasOwnProperty - Added support for standard object methods (e.g., hasOwnProperty) to QueryResultProxy, improving compatibility with typical JavaScript object usage patterns. - use hasOwnProperty to not accidentally catch other object methods
1 parent b2633c2 commit 9059150

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/runner/src/query-result-proxy.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ const arrayMethods: { [key: string]: ArrayMethodType } = {
6060
some: ArrayMethodType.ReadOnly,
6161
sort: ArrayMethodType.ReadWrite,
6262
splice: ArrayMethodType.ReadWrite,
63-
toLocaleString: ArrayMethodType.ReadOnly,
6463
toReversed: ArrayMethodType.ReadOnly,
6564
toSorted: ArrayMethodType.ReadOnly,
6665
toSpliced: ArrayMethodType.ReadOnly,
67-
toString: ArrayMethodType.ReadOnly,
6866
unshift: ArrayMethodType.WriteOnly,
6967
values: ArrayMethodType.ReadOnly,
7068
with: ArrayMethodType.ReadOnly,
69+
70+
hasOwnProperty: ArrayMethodType.ReadOnly,
71+
isPrototypeOf: ArrayMethodType.ReadOnly,
72+
propertyIsEnumerable: ArrayMethodType.ReadOnly,
73+
valueOf: ArrayMethodType.ReadOnly,
74+
toString: ArrayMethodType.ReadOnly,
75+
toLocaleString: ArrayMethodType.ReadOnly,
7176
};
7277

7378
export function createQueryResultProxy<T>(
@@ -123,7 +128,11 @@ export function createQueryResultProxy<T>(
123128
else return value;
124129
}
125130

126-
if (Array.isArray(target) && prop in arrayMethods) {
131+
if (
132+
Array.isArray(target) &&
133+
Object.prototype.hasOwnProperty.call(arrayMethods, prop) &&
134+
typeof (target[prop as keyof typeof target]) === "function"
135+
) {
127136
const method = Array.prototype[prop as keyof typeof Array.prototype];
128137
const isReadWrite = arrayMethods[prop as keyof typeof arrayMethods];
129138

0 commit comments

Comments
 (0)