github neilotoole/sq v0.45.0

latest releases: v0.48.3, v0.48.2, v0.48.1...
11 months ago

Changed

  • #335: Previously, sq didn't handle decimal values correctly. It basically shoved a decimal value into a float or string and hoped for the best. As is known, floats are imprecise, and so we saw unwanted behavior, e.g.

    db_type_test.go:194: 
          Error Trace:	D:/a/sq/sq/drivers/sqlite3/db_type_test.go:194
          Error:      	Not equal: 
                        expected: "77.77"
                        actual  : "77.77000000000001"

    Now, sq uses a dedicated Decimal type end-to-end. No precision is lost, and at the output end, the value is rendered with the correct precision.

    There is a proposal to add decimal support to the Go database/sql package. If that happens, sq will happily switch to that mechanism.

    • 👉 A side effect of decimal support is that some output formats may now render decimal values differently (i.e. correctly). In particular, Excel output should now render decimals as a number (as opposed to a string), and with the precision defined in the database. Previously, a database NUMERIC(10,5) value might have been rendered as 100.00, but will now accurately render 100.00000.

Don't miss a new sq release

NewReleases is sending notifications on new releases.