-
Notifications
You must be signed in to change notification settings - Fork 2.3k
SELECT FLOAT to float64 #308
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
Changes from 8 commits
064acea
fc1c08e
38e6bd4
af12796
855d2cf
0a6d62a
ab09bce
89b0d92
6b012d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import ( | |
"fmt" | ||
"io" | ||
"math" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
|
@@ -616,22 +617,31 @@ func (rows *textRows) readRow(dest []driver.Value) error { | |
pos += n | ||
if err == nil { | ||
if !isNull { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There shouldn't be any edits necessary in We just check for Please try if it works properly if you don't change here anything at all. According to your bug description it should work. |
||
if !mc.parseTime { | ||
// @todo hacky fix, please make it better | ||
if i > len(rows.columns)-1 { | ||
continue | ||
} else { | ||
switch rows.columns[i].fieldType { | ||
case fieldTypeTimestamp, fieldTypeDateTime, | ||
fieldTypeDate, fieldTypeNewDate: | ||
dest[i], err = parseDateTime( | ||
string(dest[i].([]byte)), | ||
mc.cfg.loc, | ||
) | ||
if err == nil { | ||
continue | ||
} | ||
default: | ||
} | ||
switch rows.columns[i].fieldType { | ||
case fieldTypeTimestamp, fieldTypeDateTime, | ||
fieldTypeDate, fieldTypeNewDate: | ||
if !mc.parseTime { | ||
continue | ||
} | ||
dest[i], err = parseDateTime( | ||
string(dest[i].([]byte)), | ||
mc.cfg.loc, | ||
) | ||
if err == nil { | ||
continue | ||
} | ||
case fieldTypeFloat: | ||
val, err := strconv.ParseFloat(string(dest[i].([]byte)), 32) | ||
dest[i] = float32(val) | ||
if err == nil { | ||
continue | ||
} | ||
default: | ||
continue | ||
} | ||
|
||
} else { | ||
|
@@ -1037,7 +1047,7 @@ func (rows *binaryRows) readRow(dest []driver.Value) error { | |
continue | ||
|
||
case fieldTypeFloat: | ||
dest[i] = float64(math.Float32frombits(binary.LittleEndian.Uint32(data[pos : pos+4]))) | ||
dest[i] = float32(math.Float32frombits(binary.LittleEndian.Uint32(data[pos : pos+4]))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pos += 4 | ||
continue | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseTime
is irrelevant here I guess. You don't need to test both versions of the DSN. Just leave outparseTime
altogether.