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];