diff --git a/src/logic/compose/generateSchema/generateSchema.ts b/src/logic/compose/generateSchema/generateSchema.ts index 00c2a17..b475ba9 100644 --- a/src/logic/compose/generateSchema/generateSchema.ts +++ b/src/logic/compose/generateSchema/generateSchema.ts @@ -24,6 +24,7 @@ export const generateSchema = async ({ configPath, targetDirPath }: { configPath ); const taskSuite = new Listr(tasks); await taskSuite.run().catch((err) => { + // console.error(err); // tslint:disable-line no-console ; // TODO: choose full error when debugging console.error(err.message); // tslint:disable-line no-console }); }; diff --git a/src/logic/generate/entityTables/generateEntityTables.ts b/src/logic/generate/entityTables/generateEntityTables.ts index fc496be..b56375f 100644 --- a/src/logic/generate/entityTables/generateEntityTables.ts +++ b/src/logic/generate/entityTables/generateEntityTables.ts @@ -21,7 +21,13 @@ export const generateEntityTables = ({ entity }: { entity: Entity }) => { }); // 2. validate the props - // TODO: throw error if the unique constraint has dynamic properties + const updatableUniqueKeys = Object.keys(updatableProps).filter((key) => entity.unique.includes(key)); + if (updatableUniqueKeys.length) + throw new Error( + `Detected a unique key on '${ + entity.name + }' which references an updatable property. This is not supported. Keys ${JSON.stringify(updatableUniqueKeys)}`, + ); // 3. define the sql const entityTable = generateTableForStaticProperties({