From 97b2d3b94c7c725f8ae2422eed4541277cf907ef Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 28 Jul 2020 10:33:17 +0200 Subject: [PATCH] ModelQuery: throw an error when fed with nonexistent relation --- src/db/ModelQuery.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/db/ModelQuery.ts b/src/db/ModelQuery.ts index b67f1d1..734c577 100644 --- a/src/db/ModelQuery.ts +++ b/src/db/ModelQuery.ts @@ -183,6 +183,7 @@ export default class ModelQuery { // Eager loading init map for (const relation of this.relations) { + if (model[relation] === undefined) throw new Error(`Relation ${relation} doesn't exist on ${model.constructor.name}.`); relationMap[relation].push(model[relation]); } }