Skip to content

Commit 6a5d457

Browse files
fixup! Support evaluation of Random.Next and NextDouble on db side
Remove invalid floor registration for decimal input: it converts it to integer, which breaks with an invalid cast NHibernate.Test.NHSpecificTest.GH0831.ByCodeFixture.CanHandleFloor using IQuery.List<Decimal>. (Well, it would also be broken with a non-casting floor, due to SQLite having a broken decimal support. But it is still invalid as floor should not change the value type.) This causes Random.Next to be unsupported for SQLite. Random.Double stays supported.
1 parent df804a8 commit 6a5d457

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

src/NHibernate/Dialect/SQLiteDialect.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@ protected virtual void RegisterFunctions()
117117
new SQLFunctionTemplate(
118118
NHibernateUtil.Double,
119119
"(cast(random() as real) / 4611686018427387904 / 4 + 0.5)"));
120-
121-
// With SQLite, casting to int truncates, so for positive values a simple cast allows to emulate floor.
122-
// But for negative values, this is a bit more complicated. Taken from
123-
// https://stackoverflow.com/q/7129249/1178314#comment8545746_7129253
124-
RegisterFunction(
125-
"floor",
126-
new SQLFunctionTemplate(
127-
NHibernateUtil.Double,
128-
"case when ?1 >= 0 then cast(?1 as int) when cast(?1 as int) = ?1 then cast(?1 as int) else cast(?1 - 1.0 as int) end"));
129120
}
130121

131122
#region private static readonly string[] DialectKeywords = { ... }

0 commit comments

Comments
 (0)