@@ -33,22 +33,28 @@ public override async Task<object> SeedAsync(ISessionImplementor session, Cancel
33
33
log . Debug ( "incoming session was null; using current application host time" ) ;
34
34
return await ( base . SeedAsync ( null , cancellationToken ) ) . ConfigureAwait ( false ) ;
35
35
}
36
- if ( ! session . Factory . Dialect . SupportsCurrentTimestampSelection )
36
+ if ( ! SupportsCurrentTimestampSelection ( session . Factory . Dialect ) )
37
37
{
38
38
log . Info ( "falling back to application host based timestamp, as dialect does not support current timestamp selection" ) ;
39
39
return await ( base . SeedAsync ( session , cancellationToken ) ) . ConfigureAwait ( false ) ;
40
40
}
41
41
return await ( GetCurrentTimestampAsync ( session , cancellationToken ) ) . ConfigureAwait ( false ) ;
42
42
}
43
43
44
+ /// <summary>
45
+ /// Retrieves the current timestamp in database.
46
+ /// </summary>
47
+ /// <param name="session">The session to use for retrieving the timestamp.</param>
48
+ /// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
49
+ /// <returns>A datetime.</returns>
44
50
protected virtual async Task < DateTime > GetCurrentTimestampAsync ( ISessionImplementor session , CancellationToken cancellationToken )
45
51
{
46
52
cancellationToken . ThrowIfCancellationRequested ( ) ;
47
53
var dialect = session . Factory . Dialect ;
48
54
// Need to round notably for Sql Server DateTime with Odbc, which has a 3.33ms resolution,
49
55
// causing stale data update failure 2/3 of times if not rounded to 10ms.
50
56
return Round (
51
- await ( UsePreparedStatementAsync ( dialect . CurrentTimestampSelectString , session , cancellationToken ) ) . ConfigureAwait ( false ) ,
57
+ await ( UsePreparedStatementAsync ( GetCurrentTimestampSelectString ( dialect ) , session , cancellationToken ) ) . ConfigureAwait ( false ) ,
52
58
dialect . TimestampResolutionInTicks ) ;
53
59
}
54
60
@@ -66,8 +72,8 @@ protected virtual async Task<DateTime> UsePreparedStatementAsync(string timestam
66
72
rs = await ( session . Batcher . ExecuteReaderAsync ( ps , cancellationToken ) ) . ConfigureAwait ( false ) ;
67
73
await ( rs . ReadAsync ( cancellationToken ) ) . ConfigureAwait ( false ) ;
68
74
var ts = rs . GetDateTime ( 0 ) ;
69
- log . Debug ( "current timestamp retreived from db : {0} (ticks={1})" , ts , ts . Ticks ) ;
70
- return ts ;
75
+ log . Debug ( "current timestamp retrieved from db : {0} (ticks={1})" , ts , ts . Ticks ) ;
76
+ return AdjustDateTime ( ts ) ;
71
77
}
72
78
catch ( DbException sqle )
73
79
{
0 commit comments