-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
If I update a nullable column with undefined, the value is changed to null.
This passes:
// Given
await testFixture.companyRepo.save(dummy.company({id: "C0", logo: Buffer.from("test", "base64")}))
// When
await testFixture.companyRepo.update("C0", {logo: undefined})
// Then
const c1 = await testFixture.companyRepo.findOneOrFail("C0")
expect(c1.logo).to.be.null
If I instead save a nullable column with undefined, the value is not changed.
This also passes:
// Given
await testFixture.companyRepo.save(dummy.company({id: "C0", logo: Buffer.from("test", "base64")}))
// When
const c1 = await testFixture.companyRepo.findOneOrFail("C0")
c1.logo = undefined
await testFixture.companyRepo.save(c1)
// Then
const c2 = await testFixture.companyRepo.findOneOrFail("C0")
expect(c2.logo).to.not.be.null
I think the behavior of save is more semantically correct.
matomesc, jeiea, eltonio450, i906, nythrox and 11 morenythrox, albertcito, ibrahimduran and YGuirautFaithful-Mind, nythrox, smovipo, albertcito, ibrahimduran and 2 more