Join GitHub today
Bug in _counter - Increment/Decrement truncates to integer. #210
When knex increment/decrement calls _counter() it uses parseInt() and truncates the incoming value to an integer. This is a problem if there is a numeric type in DB (Postgres).
I think that the _counter should do parseFloat() and if the number is given it should do nothing or just use isFinite() instead of using isNaN() that is truthy for Infinity and -Infinity.
I can provide a pull request for this one.
I put it to my existing pull request:
I did the overall refactor of the _counter() function allowing the number to be of type string or number, and I also based the '+'/'-' symbol on both: operator type (increment/decrement) and amount type (positive/negative).
I have internal unit tests for our product which are now passing. Please let me know if you can merge these changes to master.