Skip to content

Commit

Permalink
Fix for Bug#20391832, SETOBJECT() FOR TYPES.TIME RESULTS IN EXCEPTION
Browse files Browse the repository at this point in the history
WHEN VALUE HAS FRACTIONAL PART.
  • Loading branch information
soklakov committed Feb 15, 2021
1 parent ec7d1b9 commit 9269388
Show file tree
Hide file tree
Showing 27 changed files with 1,704 additions and 252 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Version 8.0.24

- Fix for Bug#20391832, SETOBJECT() FOR TYPES.TIME RESULTS IN EXCEPTION WHEN VALUE HAS FRACTIONAL PART.

- Fix for Bug#97730 (31699993), xdev api: ConcurrentModificationException at Session.close.

- Fix for Bug#99708 (31510398), mysql-connector-java 8.0.20 ASSERTION FAILED: Unknown message type: 57 s.close.
Expand Down
5 changes: 4 additions & 1 deletion src/main/core-api/java/com/mysql/cj/QueryBindings.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -38,6 +38,7 @@
import java.sql.NClob;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
Expand Down Expand Up @@ -233,4 +234,6 @@ public interface QueryBindings<T extends BindValue> {

void setLocalDateTime(int parameterIndex, LocalDateTime x, MysqlType targetMysqlType);

void setDuration(int parameterIndex, Duration x, MysqlType targetMysqlType);

}
12 changes: 11 additions & 1 deletion src/main/core-api/java/com/mysql/cj/protocol/InternalTime.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -29,6 +29,8 @@

package com.mysql.cj.protocol;

import com.mysql.cj.util.TimeUtil;

public class InternalTime {

private int hours = 0;
Expand Down Expand Up @@ -94,4 +96,12 @@ public int getScale() {
public void setScale(int scale) {
this.scale = scale;
}

@Override
public String toString() {
if (this.nanos > 0) {
return String.format("%02d:%02d:%02d.%s", this.hours, this.minutes, this.seconds, TimeUtil.formatNanos(this.nanos, this.scale, false));
}
return String.format("%02d:%02d:%02d", this.hours, this.minutes, this.seconds);
}
}
Loading

0 comments on commit 9269388

Please sign in to comment.