Skip to content

Commit 3e5652f

Browse files
committed
Set TimestampResolutionInTicks for a number of dialects that lacked it (to resolve some failing tests, e.g. DbVersionFixture.CollectionNoVersion()).
1 parent 488485e commit 3e5652f

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

src/NHibernate.Test/VersionTest/Db/DbVersionFixture.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ public void CollectionNoVersion()
8989
t.Commit();
9090
s.Close();
9191

92-
Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version was incremented");
92+
const string ownerVersionWasIncremented = "owner version was incremented ({0:o} => {1:o})";
93+
Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp),
94+
string.Format(ownerVersionWasIncremented, guyTimestamp, guy.Timestamp));
95+
Console.WriteLine(string.Format(ownerVersionWasIncremented, guyTimestamp, guy.Timestamp));
9396

9497
s = OpenSession();
9598
t = s.BeginTransaction();
@@ -98,7 +101,8 @@ public void CollectionNoVersion()
98101
t.Commit();
99102
s.Close();
100103

101-
Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp), "owner version was incremented");
104+
Assert.That(NHibernateUtil.Timestamp.IsEqual(guyTimestamp, guy.Timestamp),
105+
string.Format(ownerVersionWasIncremented, guyTimestamp, guy.Timestamp));
102106

103107
s = OpenSession();
104108
t = s.BeginTransaction();

src/NHibernate/Dialect/MsSqlCeDialect.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,14 @@ private static int GetAfterSelectInsertPoint(SqlString sql)
200200
}
201201
throw new NotSupportedException("The query should start with 'SELECT' or 'SELECT DISTINCT'");
202202
}
203+
204+
public override long TimestampResolutionInTicks
205+
{
206+
get
207+
{
208+
// MS SQL resolution is actually 3.33 ms, rounded here to 10 ms
209+
return TimeSpan.TicksPerMillisecond*10L;
210+
}
211+
}
203212
}
204213
}

src/NHibernate/Dialect/MySQLDialect.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,15 @@ public override string GetCastTypeName(SqlType sqlType)
376376
throw new HibernateException(string.Format("No CAST() type mapping for SqlType {0}", sqlType));
377377
}
378378
return result;
379+
}
380+
381+
public override long TimestampResolutionInTicks
382+
{
383+
get
384+
{
385+
// MySQL before version 5.6.4 does not support fractional seconds.
386+
return TimeSpan.TicksPerSecond;
387+
}
379388
}
380389
}
381390
}

src/NHibernate/Dialect/Oracle8iDialect.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ public override IDataBaseSchema GetDataBaseSchema(DbConnection connection)
449449
return new OracleDataBaseSchema(connection);
450450
}
451451

452+
public override long TimestampResolutionInTicks
453+
{
454+
get
455+
{
456+
// Timestamps are DateTime, which in this dialect maps to Oracle DATE,
457+
// which doesn't support fractional seconds.
458+
return TimeSpan.TicksPerSecond;
459+
}
460+
}
461+
452462
#region Overridden informational metadata
453463

454464
public override bool SupportsEmptyInList

0 commit comments

Comments
 (0)