Skip to content

Commit 16f045c

Browse files
author
vikasrohit
authored
Merge pull request #583 from maxceem/issue-582
fix: updating project with invalid templateId
2 parents 4e9bfb7 + b85e731 commit 16f045c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/models/projectTemplate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ module.exports = (sequelize, DataTypes) => {
4343
ProjectTemplate.getTemplate = templateId =>
4444
ProjectTemplate.findByPk(templateId, { raw: true })
4545
.then((template) => {
46+
// if `template` is not found by `id` return `template`
47+
if (!template) {
48+
return template; // it suppose to be `null` or whatever `findByPk` returns in this case
49+
}
50+
4651
const formRef = template.form;
4752
return formRef
4853
? models.Form.findAll({ where: formRef, raw: true })

0 commit comments

Comments
 (0)