From a494185dd72e2f620107d0cdea714e8bf80ec59c Mon Sep 17 00:00:00 2001 From: chenos Date: Tue, 22 Dec 2020 19:02:05 +0800 Subject: [PATCH] fix: belongsTo's associatedKey is Model.primaryKeyAttribute --- packages/actions/src/middlewares/associated.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/actions/src/middlewares/associated.ts b/packages/actions/src/middlewares/associated.ts index de825ed9f6..e081fcc305 100644 --- a/packages/actions/src/middlewares/associated.ts +++ b/packages/actions/src/middlewares/associated.ts @@ -24,7 +24,8 @@ export async function associated(ctx: Context, next: Next) { switch (true) { case field instanceof BELONGSTO: - key = field.options.targetKey || Model.primaryKeyAttribute; + // 如:fields.collection,对应的 API 为 /fields/119/collection,此时 key 为 PK + key = Model.primaryKeyAttribute; break; case field instanceof HASONE: case field instanceof HASMANY: