Skip to content

Commit ce850db

Browse files
committed
fix(runtime): key undefined
1 parent 184aa74 commit ce850db

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/runtime/src/enhancements/node/delegate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ export class DelegateProxyHandler extends DefaultPrismaProxyHandler {
487487
const prisma = this.prisma;
488488
const prismaModule = this.options.prismaModule;
489489
simpleTraverse(data, ({ key }) => {
490-
if (key.startsWith(DELEGATE_AUX_RELATION_PREFIX)) {
490+
if (key?.startsWith(DELEGATE_AUX_RELATION_PREFIX)) {
491491
throw prismaClientValidationError(
492492
prisma,
493493
prismaModule,

packages/runtime/src/local-helpers/simple-traverse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
type Cb = (
44
data: {
55
path: readonly string[];
6-
key: string;
6+
key: string | undefined;
77
value: any;
88
update: (nextValue: any) => void;
99
}
@@ -16,13 +16,13 @@ export function simpleTraverse<T>(root: T, cb: Cb) {
1616
function walker(node: any) {
1717
const isObject = typeof node === 'object' && node !== null;
1818
const isCircular = isObject && parents.some((p) => p === node);
19-
const key = path[path.length - 1];
2019

2120
let keepGoing = true;
2221

2322
function update(nextValue: any) {
2423
if (path.length) {
2524
const parent = parents[parents.length - 1];
25+
const key = path[path.length - 1];
2626
parent[key] = nextValue;
2727
node = nextValue;
2828
}
@@ -32,7 +32,7 @@ export function simpleTraverse<T>(root: T, cb: Cb) {
3232

3333
cb({
3434
path: [...path],
35-
key,
35+
key: path[path.length - 1],
3636
value: node,
3737
update,
3838
});

0 commit comments

Comments
 (0)