sequelize / sequelize/sequelize
Model.build strips off timestamps
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 30.4k
- Forks
- 4.3k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 68
Description
Thanks for wanting to report an issue you've found in Sequelize. Please delete this text and fill in the template below. If unsure about something, just do as best as you're able.
Note that it will be much easier for us to fix the issue if a test case that reproduces the problem is provided. Ideally this test case should not have any external dependencies. We understand that it is not always possible to reduce your code to a small test case, but we would appreciate to have as much data as possible. Thank you!
Github should only be used for feature requests and bugs - all questions belong on StackOverflow, Slack, or Google groups.
This template is for submitting issues - if you want to submit a feature request you may skip this template
What you are doing?
Post a minimal code sample that reproduces the issue, including models and associations
console.log(instance.dataValues, instance.toJSON(), Model.build(instance.toJSON()));
What do you expect to happen?
The fields should be identical in all 3 cases. The instance is a freshly selected row out of the database. No updates have occurred.
What is actually happening?
After passing instance.toJSON() into Model.build, the new returned instance does not contain createdAt or updatedAt timestamps. I am manually adding these stamps, and am not using the timestamps option.
Dialect: postgres
Database version: 9
Sequelize version: 3.30
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JavaScript reproduction in the issue and inspect the Model.build path, comparing instance.dataValues, instance.toJSON(), and Model.build(instance.toJSON()). Confirm the behavior with manually supplied createdAt and updatedAt values when the timestamps option is not used; done means the built instance retains both fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100