From f340a7d4f3f5dc8d34df40a5057ed4f1eff29784 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:32:59 -0700 Subject: [PATCH] fix: allow models without field declarations --- packages/language/src/generated/grammar.ts | 2 +- packages/language/src/zmodel.langium | 2 +- packages/schema/tests/schema/abstract.test.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/language/src/generated/grammar.ts b/packages/language/src/generated/grammar.ts index f62c3d091..986be8c33 100644 --- a/packages/language/src/generated/grammar.ts +++ b/packages/language/src/generated/grammar.ts @@ -2060,7 +2060,7 @@ export const ZModelGrammar = (): Grammar => loadedZModelGrammar ?? (loadedZModel } } ], - "cardinality": "+" + "cardinality": "*" }, { "$type": "Keyword", diff --git a/packages/language/src/zmodel.langium b/packages/language/src/zmodel.langium index b7f13466e..45bd3034f 100644 --- a/packages/language/src/zmodel.langium +++ b/packages/language/src/zmodel.langium @@ -186,7 +186,7 @@ DataModel: '{' ( fields+=DataModelField | attributes+=DataModelAttribute - )+ + )* '}'; DataModelField: diff --git a/packages/schema/tests/schema/abstract.test.ts b/packages/schema/tests/schema/abstract.test.ts index a3364bc2e..621e7998a 100644 --- a/packages/schema/tests/schema/abstract.test.ts +++ b/packages/schema/tests/schema/abstract.test.ts @@ -9,4 +9,23 @@ describe('Abstract Schema Tests', () => { }); await loadModel(content); }); + + it('empty inheritance', async () => { + await loadModel(` + datasource db { + provider = 'postgresql' + url = env('DATABASE_URL') + } + + generator js { + provider = 'prisma-client-js' + } + + abstract model Base { + id Int @id @default(autoincrement()) + } + + model Foo extends Base {} + `); + }); });