-
Notifications
You must be signed in to change notification settings - Fork 642
Closed
Description
Hi:
I recently notice when I use ts-mixer (https://www.npmjs.com/package/ts-mixer) to construct the Model with a trait, eg:
class ModelBase extends Model {...}
class ModelTrait {...}
class User extends Mixin(ModelBase, ModelTrait) {...}
this line will throw error: https://github.com/Vincit/objection.js/blob/master/lib/model/Model.js#L866. The reason is because for Mixin, somehow the modelType.prototype can be undefined in this case, which throws 'Cannot convert null or undefined to object' error.
An easy fix is to add one check here (https://github.com/Vincit/objection.js/blob/master/lib/model/Model.js#L861) so we have:
if (modelClass === Model || modelClass.prototype == undefined) {
// Stop recursion to the model class or its prototype is null or undefined
return [];
}
Is this a reasonable ask?
Metadata
Metadata
Assignees
Labels
No labels