Skip to content

Commit

Permalink
alter test
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Jan 4, 2024
1 parent 0004702 commit 004ef0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 9 additions & 6 deletions driver_test.go
Expand Up @@ -388,16 +388,16 @@ func TestCRUD(t *testing.T) {
func TestNumbersToAny(t *testing.T) {
runTestsParallel(t, dsn, func(dbt *DBTest, tbl string) {
dbt.mustExec("CREATE TABLE " + tbl + " (id INT PRIMARY KEY, b BOOL, i8 TINYINT, " +
"i16 SMALLINT, i32 INT, i64 BIGINT, f32 FLOAT, f64 DOUBLE)")
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5)")
"i16 SMALLINT, i32 INT, i64 BIGINT, f32 FLOAT, f64 DOUBLE, iu32 INT UNSIGNED)")
dbt.mustExec("INSERT INTO " + tbl + " VALUES (1, true, 127, 32767, 2147483647, 9223372036854775807, 1.25, 2.5, 4294967295)")

// Use binaryRows for intarpolateParams=false and textRows for intarpolateParams=true.
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64 FROM "+tbl+" WHERE id=?", 1)
// Use binaryRows for interpolateParams=false and textRows for interpolateParams=true.
rows := dbt.mustQuery("SELECT b, i8, i16, i32, i64, f32, f64, iu32 FROM "+tbl+" WHERE id=?", 1)
if !rows.Next() {
dbt.Fatal("no data")
}
var b, i8, i16, i32, i64, f32, f64 any
err := rows.Scan(&b, &i8, &i16, &i32, &i64, &f32, &f64)
var b, i8, i16, i32, i64, f32, f64, iu32 any
err := rows.Scan(&b, &i8, &i16, &i32, &i64, &f32, &f64, &iu32)
if err != nil {
dbt.Fatal(err)
}
Expand All @@ -422,6 +422,9 @@ func TestNumbersToAny(t *testing.T) {
if f64.(float64) != 2.5 {
dbt.Errorf("f64 != 2.5")
}
if iu32.(int64) != 4294967295 {
dbt.Errorf("iu32 != 4294967295")
}
})
}

Expand Down
7 changes: 7 additions & 0 deletions packets.go
Expand Up @@ -830,6 +830,13 @@ func (rows *textRows) readRow(dest []driver.Value) error {
case fieldTypeTiny, fieldTypeShort, fieldTypeInt24, fieldTypeYear, fieldTypeLong:
dest[i], err = strconv.ParseInt(string(buf), 10, 32)

//case fieldTypeLong:
// if rows.rs.columns[i].flags&flagUnsigned != 0 {
// dest[i], err = strconv.ParseUint(string(buf), 10, 32)
// } else {
// dest[i], err = strconv.ParseInt(string(buf), 10, 32)
// }

case fieldTypeLongLong:
if rows.rs.columns[i].flags&flagUnsigned != 0 {
dest[i], err = strconv.ParseUint(string(buf), 10, 64)
Expand Down

0 comments on commit 004ef0f

Please sign in to comment.