Skip to content

Commit

Permalink
improvement: protect preload method to be called from a deleted instance
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 27, 2020
1 parent 3d3a8f4 commit eaff60a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Orm/BaseModel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ export class BaseModel implements LucidRow {
const columnType = column.meta?.type

/**
* Return early when not dealing with date time columns
* Return early when not dealing with date time columns or auto update
* is not set to true
*/
if (!columnType || !DATE_TIME_TYPES[columnType] || !column.meta.autoUpdate) {
return
Expand Down Expand Up @@ -1367,6 +1368,7 @@ export class BaseModel implements LucidRow {
* Preloads one or more relationships for the current model
*/
public async preload (relationName: any, callback?: any) {
this.ensureIsntDeleted()
const constructor = this.constructor as LucidModel
const preloader = new Preloader(constructor)

Expand Down

0 comments on commit eaff60a

Please sign in to comment.