typeorm: UpdateDateColumn fails with transformer
Issue Description
Both the UpdateDateColumn and CreateDateColumn decorators are broken in some way for Postgres.
CreateDateColumn has no value being set on save, UpdateDateColumn does not work if the column has a transformer set on it.
Expected Behavior
On save, I’d expect TypeORM to set a createdAt date.
When I have a transformer, I’d expect TypeORM to run a new date through the transformer – or just work?
Actual Behavior
No dates are set automatically for non-nullable columns.
When I have a transformer, TypeORM makes no attempt to update the updatedAt date.
Steps to Reproduce
Both bugs are outlined here:
https://github.com/mothership/typeorm-bug
My Environment
| Dependency | Version |
|---|---|
| Operating System | OSX |
| Node.js version | v12.18.3 |
| Typescript version | v4.2.1 |
| TypeORM version | v0.2.29 |
Relevant Database Driver(s)
-
aurora-data-api -
aurora-data-api-pg -
better-sqlite3 -
cockroachdb -
cordova -
expo -
mongodb -
mysql -
nativescript -
oracle -
postgres -
react-native -
sap -
sqlite -
sqlite-abstract -
sqljs -
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time, and I know how to start.
- Yes, I have the time, but I don’t know how to start. I would need guidance.
- No, I don’t have the time, although I believe I could do it if I had the time…
- No, I don’t have the time and I wouldn’t even know how to start.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 16 (12 by maintainers)
Commits related to this issue
- Fixes bug with transformers on updatedAtColumn Because the transformer was being applied _after_ special handling logic for dates, typeorm was comparing a date object to a string object. This PR fli... — committed to mothershipper/typeorm by mothershipper 6 years ago
- Fixes bug with transformers on updatedAtColumn Because the transformer was being applied _after_ special handling logic for dates, typeorm was comparing a date object to a string object. This PR fli... — committed to mothershipper/typeorm by mothershipper 6 years ago
- fix: transformers now work on Update/CreateDateColumn Because the transformer was being applied _after_ special handling logic for dates, typeorm was comparing a date object to a string object and de... — committed to mothershipper/typeorm by mothershipper 6 years ago
Hello, Passing
to: () => undefinedseems to do the job too: