From 7c6bc43df8da70cb344c29addfdafb6f918937eb Mon Sep 17 00:00:00 2001 From: lina Date: Wed, 29 Sep 2021 13:46:00 +0200 Subject: [PATCH] look for primary key in primaryKey attribute --- src/constraints.ts | 4 ++++ src/dmmf/DmmfTypes.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/constraints.ts b/src/constraints.ts index 3bab6a5b..0e16f40d 100644 --- a/src/constraints.ts +++ b/src/constraints.ts @@ -24,6 +24,10 @@ export function resolveUniqueIdentifiers(typeName: string, dmmf: DmmfDocument): return model.idFields } + // Try finding 3. + if (model.primaryKey && model.primaryKey.fields && model.primaryKey.fields.length > 0) { + return model.primaryKey.fields; + } const singleUniqueField = model.fields.find((f) => f.isUnique) if (singleUniqueField) { diff --git a/src/dmmf/DmmfTypes.ts b/src/dmmf/DmmfTypes.ts index 837cc07d..5809ee69 100644 --- a/src/dmmf/DmmfTypes.ts +++ b/src/dmmf/DmmfTypes.ts @@ -31,6 +31,7 @@ export declare namespace InternalDMMF { idFields: string[] isEmbedded: boolean uniqueFields: Array + primaryKey: { fields?: string[] } | null } export type FieldKind = 'scalar' | 'object' | 'enum' type DatamodelFieldKind = 'scalar' | 'relation' | 'enum'