HHH-18053 TiDB timestampadd/diff pattern for fractional seconds
This commit is contained in:
parent
f45a7975c4
commit
5e9223ee5c
|
@ -11,6 +11,8 @@ import org.hibernate.dialect.sequence.SequenceSupport;
|
|||
import org.hibernate.dialect.sequence.TiDBSequenceSupport;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.query.sqm.IntervalType;
|
||||
import org.hibernate.query.sqm.TemporalUnit;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
||||
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
||||
|
@ -19,6 +21,8 @@ import org.hibernate.sql.exec.spi.JdbcOperation;
|
|||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorTiDBDatabaseImpl;
|
||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||
|
||||
import jakarta.persistence.TemporalType;
|
||||
|
||||
/**
|
||||
* A {@linkplain Dialect SQL dialect} for TiDB.
|
||||
*
|
||||
|
@ -177,4 +181,22 @@ public class TiDBDialect extends MySQLDialect {
|
|||
public FunctionalDependencyAnalysisSupport getFunctionalDependencyAnalysisSupport() {
|
||||
return FunctionalDependencyAnalysisSupportImpl.TABLE_REFERENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
|
||||
if ( unit == TemporalUnit.SECOND ) {
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue