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): prevent version number from being interpreted as string #10217

Merged
merged 1 commit into from Dec 3, 2018

Conversation

@pixelspark
Copy link
Contributor

@pixelspark pixelspark commented Dec 2, 2018

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)? --> not applicable
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

While testing with CockroachDB as backend database, I encountered a strange situation where the version number used by Sequelize for optimistic locking is (correctly) stored as INT in the table, but is incremented as string, and ends up becoming "1111...". Eventually the version number becomes too large to fit an integer. The exact same code does not show the issue when using MySQL or SQLite as backend store.

This fix ensures that the version number is incremented as a number. It merely makes the existing desired behaviour explicit and should not change the behaviour for backends where it is already working correctly.

I am not sure about how I would go about adding tests for this - more research would be needed to see whether this is CockroachDB or maybe also PostgreSQL-specific. Adding a test suite for Cockroach would be a good idea but out of my reach for now (I barely know the Sequelize source code at this point).

This happens on CockroachDB, where the version is stored as INT in the table, but is incremented as string, and ends up becoming "1111...". Eventually the version number becomes too large to fit an integer.
@codecov
Copy link

@codecov codecov bot commented Dec 3, 2018

Codecov Report

Merging #10217 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #10217   +/-   ##
=======================================
  Coverage   96.34%   96.34%           
=======================================
  Files          63       63           
  Lines        9420     9420           
=======================================
  Hits         9076     9076           
  Misses        344      344
Impacted Files Coverage Δ
lib/model.js 96.77% <100%> (ø) ⬆️

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 61a9b26...4051d4b. Read the comment docs.

@sushantdhiman sushantdhiman merged commit e4218a2 into sequelize:master Dec 3, 2018
4 checks passed
4 checks passed
@codecov
codecov/patch 100% of diff hit (target 96.34%)
Details
@codecov
codecov/project 96.34% (+0%) compared to 61a9b26
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Dec 3, 2018

Thanks @pixelspark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants