fix: use decimal notation for float formatting to match ODBC sqlcmd#706
Open
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
Open
fix: use decimal notation for float formatting to match ODBC sqlcmd#706dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
dlevy-msft-sql wants to merge 2 commits intomicrosoft:mainfrom
Conversation
ODBC sqlcmd displays floats like 4713347.3103808956 while go-sqlcmd was using scientific notation like 4.713347310380896e+06. Now uses decimal notation for typical values, with fallback to scientific notation for extreme values that would exceed column width.
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
go-sqlcmd displays float values using scientific notation while ODBC sqlcmd uses decimal notation:
4.713347310380896e+064713347.3103808956This causes compatibility issues for scripts expecting consistent output.
Root Cause
Float values were falling through to the default
fmt.Sprintf("%v", x)case which uses Go's default formatting (scientific notation for large values).Code Change
Added explicit float formatting using
strconv.FormatFloatwith'f'format for decimal notation:realDefaultWidth=14,floatDefaultWidth=24)Testing
go build ./...TestFormatterFloatDecimalNotation- verifies decimal notation for typical valuesTestFormatterFloatScientificFallback- verifies scientific notation for extreme valuesFixes #555