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

Fix zeros stripped in conversion from numeric #111

Merged
merged 8 commits into from
Nov 6, 2018

Conversation

michal-tomlein
Copy link
Contributor

Fixes a bug causing zeros to be stripped from numeric values such as 10234.543201, producing 1234.54321.

Fixes a bug causing zeros to be stripped from numeric values such as 10234, producing 1234.
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! A test to ensure this new code works and to prevent regressions in the future would be great.

@@ -48,10 +48,10 @@ extension String: PostgreSQLDataConvertible {

/// depending on our offset, append the string to before or after the decimal point
if offset < metadata.weight.bigEndian + 1 {
integer += string
integer += offset == 0 ? string : String(repeating: "0", count: 4 - string.count) + string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking this up into one or two lines with some comments would make it a lot more readable I think

@tanner0101 tanner0101 added the bug Something isn't working label Nov 5, 2018
@tanner0101 tanner0101 self-assigned this Nov 5, 2018
@tanner0101 tanner0101 added this to the 1.1.1 milestone Nov 5, 2018
@tanner0101 tanner0101 removed this from the 1.1.1 milestone Nov 5, 2018
@michal-tomlein
Copy link
Contributor Author

michal-tomlein commented Nov 5, 2018 via email

@michal-tomlein michal-tomlein force-pushed the numeric-zeros-bug branch 2 times, most recently from 6bfd36d to fbb2238 Compare November 6, 2018 10:12
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @michal-tomlein. I really appreciate you taking the time to submit this patch and a thorough test case.

@tanner0101 tanner0101 added this to the 1.1.2 milestone Nov 6, 2018
@tanner0101 tanner0101 merged commit 975cc8b into vapor:master Nov 6, 2018
@penny-coin
Copy link

Hey @michal-tomlein, you just merged a pull request, have a coin!

You now have 1 coins.

@michal-tomlein michal-tomlein deleted the numeric-zeros-bug branch November 6, 2018 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants