Ver código fonte

This commit attempts to fix https://github.com/go-sql-driver/mysql/issues/139 by
using an empty string ("") instead of the 0 byte []byte('0') when
formatting positive TIME fields.

Carlos Nieto 12 anos atrás
pai
commit
ed7d90706a
1 arquivos alterados com 4 adições e 6 exclusões
  1. 4 6
      packets.go

+ 4 - 6
packets.go

@@ -1137,16 +1137,15 @@ func (rows *mysqlRows) readBinaryRow(dest []driver.Value) error {
 				}
 			}
 
-			var sign byte
+			var sign string
 			if data[pos] == 1 {
-				sign = byte('-')
+				sign = "-"
 			}
 
 			switch num {
 			case 8:
 				dest[i] = []byte(fmt.Sprintf(
-					"%c%02d:%02d:%02d",
-					sign,
+					sign+"%02d:%02d:%02d",
 					uint16(data[pos+1])*24+uint16(data[pos+5]),
 					data[pos+6],
 					data[pos+7],
@@ -1155,8 +1154,7 @@ func (rows *mysqlRows) readBinaryRow(dest []driver.Value) error {
 				continue
 			case 12:
 				dest[i] = []byte(fmt.Sprintf(
-					"%c%02d:%02d:%02d.%06d",
-					sign,
+					sign+"%02d:%02d:%02d.%06d",
 					uint16(data[pos+1])*24+uint16(data[pos+5]),
 					data[pos+6],
 					data[pos+7],