Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(model): handle true timestamp fields correctly #12580

Merged
merged 5 commits into from Aug 1, 2020

Conversation

vishal-sood
Copy link
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

  • Updated Model.init method to accept only string and boolean values for the timestamp fields; throw an Error if some other value is passed
  • Prevent a column named "true" from being created on the model whenever any timestamp fields (viz. createdAt, updatedAt, deletedAt) is set to true
  • Add tests for both the scenarios

Fixes #12551

vishal-sood and others added 5 commits August 1, 2020 01:38
Updated Model.init method to accept only string and boolean values. Also, prevent a column
named `true` from being created on the model whenever any timestamp fields (viz. 'createdAt',
'updatedAt', 'deletedAt') is set to `true`

Closes sequelize#12551
Added tests to check the following:
 - Model.init throws Error when any timestamp field has value other than string or boolean
 - Model.init doesn't create a column named `true` when any timestamp field is set to true
@codecov
Copy link

codecov bot commented Aug 1, 2020

Codecov Report

Merging #12580 into master will decrease coverage by 0.47%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12580      +/-   ##
==========================================
- Coverage   96.33%   95.85%   -0.48%     
==========================================
  Files          95       92       -3     
  Lines        9256     9057     -199     
  Branches       90       90              
==========================================
- Hits         8917     8682     -235     
- Misses        322      358      +36     
  Partials       17       17              
Impacted Files Coverage Δ
src/model.js 96.52% <87.50%> (-0.06%) ⬇️
src/dialects/mariadb/query-generator.js 18.75% <0.00%> (-81.25%) ⬇️
src/dialects/mariadb/data-types.js 47.36% <0.00%> (-52.64%) ⬇️
src/dialects/abstract/query-interface.js 92.28% <0.00%> (-1.86%) ⬇️
src/sequelize.js 94.90% <0.00%> (-0.64%) ⬇️
src/dialects/mariadb/query.js
src/dialects/mariadb/index.js
src/dialects/mariadb/connection-manager.js

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19976a8...c27ecbd. Read the comment docs.

@papb papb changed the title fix(model): handle timestamp fields set to true fix(model): handle true timestamp fields correctly Aug 1, 2020
@papb
Copy link
Member

papb commented Aug 1, 2020

Hello! I see you are a first-time contributor, thank you for taking the time to help Sequelize! I hope to see more PRs from you in the future!

Fantastic work!!

@papb papb merged commit a2d75e6 into sequelize:master Aug 1, 2020
papb added a commit that referenced this pull request Aug 1, 2020
Co-authored-by: Pedro Augusto de Paula Barbosa <papb1996@gmail.com>
papb added a commit that referenced this pull request Aug 1, 2020
Co-authored-by: Pedro Augusto de Paula Barbosa <papb1996@gmail.com>
Co-authored-by: Vishal Sood <vishalsood1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sequelize create in the tables a column called "true"
2 participants