-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 increment/decrement method float bug #1069
Conversation
The increment/decrement method would convert float numbers to integers instead of leaving them as is.
Implementation looks good, but it seems to be missing test case for it. |
Sorry can't manage to run integration tests. Maybe merge this and open another issue? |
I was pulling my hair out for a bit trying to figure out why decrement didn't work, so I dug into the source code and realized it did parseInt... |
@olalonde Just write the test and push to the PR, Travis will run it for you. If it fails you can just fix it and push again. (Or set up the test environment - a bit more involved.) Also I agree with @chrisbroome that |
Thinking on this more - I'm actually not in favor of this change. These methods are meant to be for use with 'counter' style columns. The default of When dealing with floating point numbers it would make more sense to have methods knex('table').update({ column: knex.raw('?? + ?', column, 1.5) }).then(result => If you want to support writing arbitrary statements like this without using const { column, value } = knex.statement;
knex('table').update({
thing: column('thing').plus(1.5), // "thing" = "thing" + 1.5
other: column('other').times(column('thing')), // "other" = "other" * "thing"
thingy: value(3).plus(1.5) // "thingy" = 3 + 1.5
).then(result => |
That's a lot of bike-shedding over a removed parseInt call. People who want to use increment/decrement with integers still can. People who want to increment/decrement floats will now be able to. Simple as that. Can we just merge this and open another issue for the unrelated stuff? |
Fair enough @olalonde. I was waiting for the change to |
Thanks. |
Hey @olalonde, did you end up writing a test for this? |
Closing abandoned pull request, I'll update the issue mentioning that here is almost ready pull request if someone feels like finishing this. |
The increment/decrement method would convert float numbers
to integers instead of leaving them as is.
Fixes #868