Browse Source

Don't write microseconds when Time.Nanosecond() == 0

INADA Naoki 11 years ago
parent
commit
9faabe593d
1 changed files with 3 additions and 0 deletions
  1. 3 0
      connection.go

+ 3 - 0
connection.go

@@ -208,6 +208,9 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
 				parts[pos] = "'0000-00-00'"
 			} else {
 				fmt := "'2006-01-02 15:04:05.999999'"
+				if v.Nanosecond() == 0 {
+					fmt = "'2006-01-02 15:04:05'"
+				}
 				parts[pos] = v.In(mc.cfg.loc).Format(fmt)
 			}
 		case []byte: