Fix TiDB timestampdiff pattern

This commit is contained in:
Marco Belladelli 2024-05-06 17:36:20 +02:00 committed by Christian Beikov
parent d1b30e1ab8
commit 5512281a5e
1 changed files with 1 additions and 10 deletions

View File

@ -184,19 +184,10 @@ public class TiDBDialect extends MySQLDialect {
@Override
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
if ( unit == TemporalUnit.SECOND ) {
if ( unit == TemporalUnit.SECOND && intervalType == null ) {
// TiDB doesn't natively support adding fractional seconds
return "timestampadd(microsecond,?2*1e6,?3)";
}
return super.timestampaddPattern( unit, temporalType, intervalType );
}
@Override
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
if ( unit == TemporalUnit.SECOND ) {
// TiDB doesn't natively support adding fractional seconds
return "timestampadd(microsecond,?2*1e6,?3)";
}
return super.timestampdiffPattern( unit, fromTemporalType, toTemporalType );
}
}