Skip to content

Commit

Permalink
fix large num parser
Browse files Browse the repository at this point in the history
  • Loading branch information
hantmac committed Nov 6, 2022
1 parent 5ab8edd commit bad7dd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions dataparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,30 +476,32 @@ func (p *intParser) Parse(s io.RuneScanner) (driver.Value, error) {
}

if p.signed {
v, err := strconv.ParseInt(repr, 10, p.bitSize)
f, err := strconv.ParseFloat(repr, 10)
//v, err := strconv.ParseInt(repr, 10, p.bitSize)
switch p.bitSize {
case 8:
return int8(v), err
return int8(f), err
case 16:
return int16(v), err
return int16(f), err
case 32:
return int32(v), err
return int32(f), err
case 64:
return int64(v), err
return int64(f), err
default:
panic("unsupported bit size")
}
} else {
v, err := strconv.ParseUint(repr, 10, p.bitSize)
f, err := strconv.ParseFloat(repr, 10)
//v, err := strconv.ParseUint(repr, 10, p.bitSize)
switch p.bitSize {
case 8:
return uint8(v), err
return uint8(f), err
case 16:
return uint16(v), err
return uint16(f), err
case 32:
return uint32(v), err
return uint32(f), err
case 64:
return uint64(v), err
return uint64(f), err
default:
panic("unsupported bit size")
}
Expand Down
1 change: 1 addition & 0 deletions rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (r *nextRows) Next(dest []driver.Value) error {
reader := strings.NewReader(fmt.Sprintf("%v", lineData[j]))
v, err := r.parsers[j].Parse(reader)
if err != nil {
r.dc.log("parse error ", err)
return err
}
dest[j] = v
Expand Down

0 comments on commit bad7dd4

Please sign in to comment.