Skip to content
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

Increment floats #2614

Merged
merged 3 commits into from May 19, 2018
Merged

Increment floats #2614

merged 3 commits into from May 19, 2018

Conversation

thecodeboss
Copy link
Contributor

Fixes #868 and #1990.

For a query such as:

knex('accounts').where('id', 1).increment('balance', 0.1);

the expected sql is

update "accounts" set "balance" = "balance" + 0.1 where "id" = 1

however, the actual sql is

update "accounts" set "balance" = "balance" + 0 where "id" = 1

The problem is that parseInt is being used instead of parseFloat in the builder code.

I tried my best to write lots of tests, and I had to add a float column to the existing integration test account schema to properly test this. This is my first time contributing to this repo, so apologies if I missed anything in the process.

@thecodeboss thecodeboss reopened this May 18, 2018
@elhigu
Copy link
Member

elhigu commented May 19, 2018

Looks good 👍

@elhigu elhigu merged commit db390b1 into knex:master May 19, 2018
@elhigu
Copy link
Member

elhigu commented May 19, 2018

thanks a lot!

@thecodeboss thecodeboss deleted the increment-floats branch May 20, 2018 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants