fix(model): prevent version number from being interpreted as string #10217
Pull Request check-list
Please make sure to review and check all of these items:
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.
@@ Coverage Diff @@ ## master #10217 +/- ## ======================================= Coverage 96.34% 96.34% ======================================= Files 63 63 Lines 9420 9420 ======================================= Hits 9076 9076 Misses 344 344