From de6a2202703c149a108b8d169c9f8fc9ca816c82 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Tue, 12 Mar 2024 11:40:08 +0100 Subject: [PATCH] fix: make sure that its a nested path --- packages/postgrest-core/src/delete-fetcher.ts | 4 +++- packages/postgrest-core/src/update-fetcher.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/postgrest-core/src/delete-fetcher.ts b/packages/postgrest-core/src/delete-fetcher.ts index df2400ac..d7ad0767 100644 --- a/packages/postgrest-core/src/delete-fetcher.ts +++ b/packages/postgrest-core/src/delete-fetcher.ts @@ -13,6 +13,7 @@ import { BuildNormalizedQueryOps, buildNormalizedQuery, } from './fetch/build-normalized-query'; +import { isNestedPath } from './lib/group-paths-recursive'; export type DeleteFetcher = ( input: Partial[], @@ -45,7 +46,8 @@ export const buildDeleteFetcher = const query = buildNormalizedQuery(opts); const pkAlias = (path: string): string => - query?.paths.find((p) => p.path === path)?.alias || path; + query?.paths.find((p) => p.path === path && !isNestedPath(p))?.alias || + path; if (primaryKeys.length === 1) { const primaryKey = primaryKeys[0] as string; diff --git a/packages/postgrest-core/src/update-fetcher.ts b/packages/postgrest-core/src/update-fetcher.ts index a9a32204..815ee166 100644 --- a/packages/postgrest-core/src/update-fetcher.ts +++ b/packages/postgrest-core/src/update-fetcher.ts @@ -13,6 +13,7 @@ import { buildNormalizedQuery, BuildNormalizedQueryOps, } from './fetch/build-normalized-query'; +import { isNestedPath } from './lib/group-paths-recursive'; export type UpdateFetcher = ( input: Partial, @@ -45,7 +46,8 @@ export const buildUpdateFetcher = const query = buildNormalizedQuery(opts); const pkAlias = (path: string): string => - query?.paths.find((p) => p.path === path)?.alias || path; + query?.paths.find((p) => p.path === path && !isNestedPath(p))?.alias || + path; for (const key of primaryKeys) { const value = input[key];