more javadoc for Dialect.getFractionalSecondPrecisionInNanos()
This commit is contained in:
parent
56774f80d7
commit
8f29ae95c9
|
@ -276,7 +276,6 @@ public class SybaseASELegacyDialect extends SybaseLegacyDialect {
|
|||
|
||||
@Override
|
||||
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
|
||||
//TODO!!
|
||||
switch ( unit ) {
|
||||
case NANOSECOND:
|
||||
return "dateadd(ms,?2/1000000,?3)";
|
||||
|
@ -291,7 +290,6 @@ public class SybaseASELegacyDialect extends SybaseLegacyDialect {
|
|||
|
||||
@Override
|
||||
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
||||
//TODO!!
|
||||
switch ( unit ) {
|
||||
case NANOSECOND:
|
||||
return "(cast(datediff(ms,?2,?3) as numeric(21))*1000000)";
|
||||
|
|
|
@ -4621,7 +4621,22 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
|
|||
*
|
||||
* @return the precision, specified as a quantity of
|
||||
* nanoseconds
|
||||
*
|
||||
* @see TemporalUnit#NATIVE
|
||||
*
|
||||
* @implNote Getting this right is very important. It
|
||||
* would be great if all platforms supported
|
||||
* datetime arithmetic with nanosecond
|
||||
* precision, since that is how we represent
|
||||
* {@link Duration}. But they don't, and we
|
||||
* don't want to fill up the SQL expression
|
||||
* with many conversions to/from nanoseconds.
|
||||
* (Not to mention the problems with numeric
|
||||
* overflow that this sometimes causes.) So
|
||||
* we need to pick the right value here,
|
||||
* and implement {@link #timestampaddPattern}
|
||||
* and {@link #timestampdiffPattern} consistent
|
||||
* with our choice.
|
||||
*/
|
||||
public long getFractionalSecondPrecisionInNanos() {
|
||||
return 1; //default to nanoseconds for now
|
||||
|
|
|
@ -723,7 +723,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
|||
|
||||
/**
|
||||
* SQL server supports up to 7 decimal digits of
|
||||
* fractional second precision in a datetime2,
|
||||
* fractional second precision in {@code datetime2},
|
||||
* but unfortunately its duration arithmetic
|
||||
* functions have a nasty habit of overflowing.
|
||||
* So to give ourselves a little extra headroom,
|
||||
|
@ -778,16 +778,18 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
|||
|
||||
@Override
|
||||
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
||||
if ( unit == TemporalUnit.NATIVE ) {//use microsecond as the "native" precision
|
||||
if ( unit == TemporalUnit.NATIVE ) {
|
||||
//use microsecond as the "native" precision
|
||||
return "datediff_big(microsecond,?2,?3)";
|
||||
}
|
||||
|
||||
//datediff() returns an int, and can easily
|
||||
//overflow when dealing with "physical"
|
||||
//durations, so use datediff_big()
|
||||
return unit.normalized() == NANOSECOND
|
||||
? "datediff_big(?1,?2,?3)"
|
||||
: "datediff(?1,?2,?3)";
|
||||
else {
|
||||
//datediff() returns an int, and can easily
|
||||
//overflow when dealing with "physical"
|
||||
//durations, so use datediff_big()
|
||||
return unit.normalized() == NANOSECOND
|
||||
? "datediff_big(?1,?2,?3)"
|
||||
: "datediff(?1,?2,?3)";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -796,8 +798,9 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
|||
if ( unit == TemporalUnit.NATIVE ) {
|
||||
return "microsecond";
|
||||
}
|
||||
|
||||
return super.translateDurationField( unit );
|
||||
else {
|
||||
return super.translateDurationField( unit );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -261,17 +261,22 @@ public class SybaseASEDialect extends SybaseDialect {
|
|||
return "current_bigdatetime()";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sybase ASE in principle supports microsecond
|
||||
* precision for {code bigdatetime}, but
|
||||
* unfortunately its duration arithmetic
|
||||
* functions have a nasty habit of overflowing.
|
||||
* So to give ourselves a little extra headroom,
|
||||
* we will use {@code millisecond} as the native
|
||||
* unit of precision.
|
||||
*/
|
||||
@Override
|
||||
public long getFractionalSecondPrecisionInNanos() {
|
||||
// Sybase supports microsecond precision
|
||||
// but when we use it we just get numerical
|
||||
// overflows from timestamp arithmetic
|
||||
return 1_000_000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
|
||||
//TODO!!
|
||||
switch ( unit ) {
|
||||
case NANOSECOND:
|
||||
return "dateadd(ms,?2/1000000,?3)";
|
||||
|
@ -286,7 +291,6 @@ public class SybaseASEDialect extends SybaseDialect {
|
|||
|
||||
@Override
|
||||
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
||||
//TODO!!
|
||||
switch ( unit ) {
|
||||
case NANOSECOND:
|
||||
return "(cast(datediff(ms,?2,?3) as numeric(21))*1000000)";
|
||||
|
|
Loading…
Reference in New Issue