Skip to content

Commit

Permalink
add handle for negative timezone (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: AmoebaProtozoa <8039876+AmoebaProtozoa@users.noreply.github.com>
  • Loading branch information
AmoebaProtozoa authored Sep 30, 2021
1 parent d74b2a0 commit b6638bb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,24 @@ func parseBindArgs(sc *stmtctx.StatementContext, args []types.Datum, paramTypes
case mysql.TypeTimestamp:
// we ignore timezone here
timeStr := string(bind.Parameters[i])
tzIndex := strings.Index(timeStr, " +")
if tzIndex == -1 {
args[i] = types.NewDatum(timeStr)
// some timezone start with +, for example +08:00:00, or -, like -04:00:00
pluesIndex := strings.Index(timeStr, " +")
if pluesIndex > 0 {
noTzStr := timeStr[:pluesIndex]
args[i] = types.NewDatum(noTzStr)
continue
}
noTzStr := timeStr[:tzIndex]
args[i] = types.NewDatum(noTzStr)

minusIndex := strings.Index(timeStr, " -")
if minusIndex > 0 {
noTzStr := timeStr[:minusIndex]
args[i] = types.NewDatum(noTzStr)
continue
}

args[i] = types.NewDatum(timeStr)
continue

case mysql.TypeDate, mysql.TypeDatetime:
// fixme 日期待测试 待修复
args[i] = types.NewDatum(string(bind.Parameters[i]))
Expand Down

0 comments on commit b6638bb

Please sign in to comment.