Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 3aa9cdc

Browse files
committed
common: Fix conversion of numbers to strings when reading rows
When reading in the results of a query numbers are converted to strings for later use. For integers we want to use 64bit integers internally to make sure every possible integer fits in our variables. For floats we want to make sure we use the highest required precision when converting the number to a string instead of rounding early.
1 parent 65146a6 commit 3aa9cdc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/sqlite.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,10 @@ func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, i
730730
isNull := false
731731
switch fieldType {
732732
case sqlite.Integer:
733-
var val int
734-
val, isNull, err = s.ScanInt(i)
733+
var val int64
734+
val, isNull, err = s.ScanInt64(i)
735735
if err != nil {
736-
log.Printf("Something went wrong with ScanInt(): %v\n", err)
736+
log.Printf("Something went wrong with ScanInt64(): %v\n", err)
737737
break
738738
}
739739
if !isNull {
@@ -748,7 +748,7 @@ func SQLiteRunQuery(sdb *sqlite.Conn, querySource QuerySource, dbQuery string, i
748748
break
749749
}
750750
if !isNull {
751-
stringVal := strconv.FormatFloat(val, 'f', 4, 64)
751+
stringVal := strconv.FormatFloat(val, 'f', -1, 64)
752752
row = append(row, DataValue{Name: dataRows.ColNames[i], Type: Float, Value: stringVal})
753753
}
754754
case sqlite.Text:

0 commit comments

Comments
 (0)