Skip to content

Commit a2979c2

Browse files
committed
v1.8.15
1 parent 112b245 commit a2979c2

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Release Notes
55

66
### Minor revisions
77

8+
#### v1.8.15
9+
- fixed sql value conversion for integers and floats
10+
811
#### v1.8.14
912
- fixed race condition in writing metrics
1013

driver/datatype_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,42 +350,82 @@ const (
350350
maxDouble = math.MaxFloat64
351351
)
352352

353+
type (
354+
testUint8 uint8
355+
testInt8 int8
356+
)
357+
353358
var tinyintTestData = []any{
359+
testUint8(minTinyint),
360+
testUint8(maxTinyint),
361+
testInt8(minTinyint),
354362
uint8(minTinyint),
355363
uint8(maxTinyint),
356364
sql.NullInt64{Valid: false, Int64: minTinyint},
357365
sql.NullInt64{Valid: true, Int64: maxTinyint},
358366
}
359367

368+
type (
369+
testUint16 uint16
370+
testInt16 int16
371+
)
372+
360373
var smallintTestData = []any{
374+
testUint16(maxSmallint),
375+
testInt16(minSmallint),
376+
testInt16(maxSmallint),
361377
int16(minSmallint),
362378
int16(maxSmallint),
363379
sql.NullInt64{Valid: false, Int64: minSmallint},
364380
sql.NullInt64{Valid: true, Int64: maxSmallint},
365381
}
366382

383+
type (
384+
testUint32 uint32
385+
testInt32 int32
386+
)
387+
367388
var integerTestData = []any{
389+
testUint32(maxInteger),
390+
testInt32(minInteger),
391+
testInt32(maxInteger),
368392
int32(minInteger),
369393
int32(maxInteger),
370394
sql.NullInt64{Valid: false, Int64: minInteger},
371395
sql.NullInt64{Valid: true, Int64: maxInteger},
372396
}
373397

398+
type (
399+
testUint64 uint64
400+
testInt64 int64
401+
)
402+
374403
var bigintTestData = []any{
404+
testUint64(maxBigint),
405+
testInt64(minBigint),
406+
testInt64(maxBigint),
375407
int64(minBigint),
376408
int64(maxBigint),
377409
sql.NullInt64{Valid: false, Int64: minBigint},
378410
sql.NullInt64{Valid: true, Int64: maxBigint},
379411
}
380412

413+
type testFloat32 float32
414+
381415
var realTestData = []any{
416+
testFloat32(-maxReal),
417+
testFloat32(maxReal),
382418
float32(-maxReal),
383419
float32(maxReal),
384420
sql.NullFloat64{Valid: false, Float64: -maxReal},
385421
sql.NullFloat64{Valid: true, Float64: maxReal},
386422
}
387423

424+
type testFloat64 float64
425+
388426
var doubleTestData = []any{
427+
testFloat64(-maxDouble),
428+
testFloat64(maxDouble),
389429
float64(-maxDouble),
390430
float64(maxDouble),
391431
sql.NullFloat64{Valid: false, Float64: -maxDouble},

driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// DriverVersion is the version number of the hdb driver.
13-
const DriverVersion = "1.8.14"
13+
const DriverVersion = "1.8.15"
1414

1515
// DriverName is the driver name to use with sql.Open for hdb databases.
1616
const DriverName = "hdb"

driver/internal/protocol/convert.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func convertInteger(tc typeCode, v any, min, max int64) (any, error) {
124124
if i64 > max || i64 < min {
125125
return nil, newConvertError(tc, v, ErrIntegerOutOfRange)
126126
}
127-
return v, nil
127+
return i64, nil
128128
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
129129
u64 := rv.Uint()
130130
if u64 >= 1<<63 {
@@ -133,7 +133,7 @@ func convertInteger(tc typeCode, v any, min, max int64) (any, error) {
133133
if int64(u64) > max || int64(u64) < min {
134134
return nil, newConvertError(tc, v, ErrIntegerOutOfRange)
135135
}
136-
return v, nil
136+
return u64, nil
137137
// conversions with allocations (return i64)
138138
case reflect.Float32, reflect.Float64:
139139
f64 := rv.Float()
@@ -178,10 +178,11 @@ func convertFloat(tc typeCode, v any, max float64) (any, error) {
178178
switch rv.Kind() {
179179
// conversions without allocations (return v)
180180
case reflect.Float32, reflect.Float64:
181-
if math.Abs(rv.Float()) > max {
181+
f64 := rv.Float()
182+
if math.Abs(f64) > max {
182183
return nil, newConvertError(tc, v, ErrFloatOutOfRange)
183184
}
184-
return v, nil
185+
return f64, nil
185186
// conversions with allocations (return f64)
186187
case reflect.String:
187188
f64, err := strconv.ParseFloat(rv.String(), 64)

0 commit comments

Comments
 (0)