fix(model): prevent version number from being interpreted as string#10217
Merged
sushantdhiman merged 1 commit intosequelize:masterfrom Dec 3, 2018
Merged
fix(model): prevent version number from being interpreted as string#10217sushantdhiman merged 1 commit intosequelize:masterfrom
sushantdhiman merged 1 commit intosequelize:masterfrom
Conversation
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 Report
@@ Coverage Diff @@
## master #10217 +/- ##
=======================================
Coverage 96.34% 96.34%
=======================================
Files 63 63
Lines 9420 9420
=======================================
Hits 9076 9076
Misses 344 344
Continue to review full report at Codecov.
|
Contributor
|
Thanks @pixelspark |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?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).