Skip to content

Commit

Permalink
added support for colType 16 (numeric) (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
huebnerr authored and sitingren committed Jul 25, 2019
1 parent 9fd62fc commit 9e194a1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
ColTypeVarChar uint32 = 9
ColTypeTimestamp uint32 = 12
ColTypeTimestampTZ uint32 = 13
ColTypeNumeric uint32 = 16
ColTypeVarBinary uint32 = 17
ColTypeUUID uint32 = 20
ColTypeLongVarChar uint32 = 115
Expand Down
2 changes: 1 addition & 1 deletion driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Driver struct{}

const (
driverName string = "vertica-sql-go"
driverVersion string = "0.1.0"
driverVersion string = "0.1.1"
protocolVersion uint32 = 0x00030008
)

Expand Down
22 changes: 22 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,28 @@ func TestEmptyStatmentError(t *testing.T) {
assertErr(t, err, "empty statement")
}

func TestNumericColumnType(t *testing.T) {
connDB, err := sql.Open("vertica", myDBConnectString)
assertNoErr(t, err)

defer connDB.Close()

ctx := context.Background()

err = connDB.PingContext(ctx)
assertNoErr(t, err)

rows, err := connDB.QueryContext(ctx, "SELECT (1/10000000000) as result")
assertNoErr(t, err)
assertNext(t, rows)

var resultFloat float64
rows.Scan(&resultFloat)
assertEqual(t, resultFloat, float64(0.0000000001))

rows.Close()
}

func init() {
logger.SetLogLevel(logger.TRACE)

Expand Down
2 changes: 1 addition & 1 deletion rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (r *rows) Next(dest []driver.Value) error {
} else {
dest[idx] = string(colVal)
}
case common.ColTypeFloat64: // to float64
case common.ColTypeFloat64, common.ColTypeNumeric: // to float64
if colVal == nil {
dest[idx] = sql.NullFloat64{}
} else {
Expand Down

0 comments on commit 9e194a1

Please sign in to comment.