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

Bug in _counter - Increment/Decrement truncates to integer. #210

kobalicek opened this Issue Mar 19, 2014 · 2 comments


None yet
2 participants

kobalicek commented Mar 19, 2014

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.


This comment has been minimized.


tgriesser commented Mar 19, 2014

Ah, yeah that's no good. A pull request would be great, thanks!


This comment has been minimized.


kobalicek commented Mar 20, 2014

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.


@kobalicek kobalicek closed this Mar 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment