Skip to content

Commit 004ef0f

Browse files
committed
alter test
1 parent 0004702 commit 004ef0f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

driver_test.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,16 @@ func TestCRUD(t *testing.T) {
388388
func TestNumbersToAny(t *testing.T) {
389389
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
390390
dbt.mustExec("CREATE TABLE " + tbl + " (id INT PRIMARY KEY, b BOOL, i8 TINYINT, " +
391-
"i16 SMALLINT, i32 INT, i64 BIGINT, f32 FLOAT, f64 DOUBLE)")
392-
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5)")
391+
"i16 SMALLINT, i32 INT, i64 BIGINT, f32 FLOAT, f64 DOUBLE, iu32 INT UNSIGNED)")
392+
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5, 4294967295)")
393393

394-
// Use binaryRows for intarpolateParams=false and textRows for intarpolateParams=true.
395-
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64 FROM "+tbl+" WHERE id=?", 1)
394+
// Use binaryRows for interpolateParams=false and textRows for interpolateParams=true.
395+
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64, iu32 FROM "+tbl+" WHERE id=?", 1)
396396
if !rows.Next() {
397397
dbt.Fatal("no data")
398398
}
399-
var b, i8, i16, i32, i64, f32, f64 any
400-
err := rows.Scan(&b, &i8, &i16, &i32, &i64, &f32, &f64)
399+
var b, i8, i16, i32, i64, f32, f64, iu32 any
400+
err := rows.Scan(&b, &i8, &i16, &i32, &i64, &f32, &f64, &iu32)
401401
if err != nil {
402402
dbt.Fatal(err)
403403
}
@@ -422,6 +422,9 @@ func TestNumbersToAny(t *testing.T) {
422422
if f64.(float64) != 2.5 {
423423
dbt.Errorf("f64 != 2.5")
424424
}
425+
if iu32.(int64) != 4294967295 {
426+
dbt.Errorf("iu32 != 4294967295")
427+
}
425428
})
426429
}
427430

packets.go

+7
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,13 @@ func (rows *textRows) readRow(dest []driver.Value) error {
830830
case fieldTypeTiny, fieldTypeShort, fieldTypeInt24, fieldTypeYear, fieldTypeLong:
831831
dest[i], err = strconv.ParseInt(string(buf), 10, 32)
832832

833+
//case fieldTypeLong:
834+
// if rows.rs.columns[i].flags&flagUnsigned != 0 {
835+
// dest[i], err = strconv.ParseUint(string(buf), 10, 32)
836+
// } else {
837+
// dest[i], err = strconv.ParseInt(string(buf), 10, 32)
838+
// }
839+
833840
case fieldTypeLongLong:
834841
if rows.rs.columns[i].flags&flagUnsigned != 0 {
835842
dest[i], err = strconv.ParseUint(string(buf), 10, 64)

0 commit comments

Comments
 (0)