typeorm: BeforeUpdate does not include `select: false` columns

Issue type:

[x] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x] postgres [ ] sqlite [ ] sqljs [ ] websql

TypeORM version:

[ ] latest [ ] @next [x] 0.1.11 (or put your version here)

Steps to reproduce or a small repository showing the problem:

If you apply:

@Column({select: false})
password: string

And then try to print that property when using BeforeUpdate:

  @BeforeUpdate()
beforeUpdate() {
  console.log(this.password); // Gives `undefined`
}

I would suggest using some option in BeforeUpdate or something along those lines in order to be able to get select: false columns, as I think it makes sense not to have this showing

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Something like this:

@BeforeUpdate()
async update() {
      const sameUserWithPwd = await getRepository(User)
           .createQueryBuilder("user")
           .addSelect("user.password")
           .where("user.id = :id", { id: this.id })
          .getOne();
}