From 3b2980ab9aef638c5caffc39255fdaecfd9d96a0 Mon Sep 17 00:00:00 2001 From: maca88 Date: Tue, 26 May 2020 20:15:57 +0200 Subject: [PATCH] Fix Oracle binary floating point setting --- .../Async/Linq/ByMethod/AverageTests.cs | 23 ------------------- .../Linq/ByMethod/AverageTests.cs | 23 ------------------- src/NHibernate/Dialect/Oracle10gDialect.cs | 4 ++-- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/src/NHibernate.Test/Async/Linq/ByMethod/AverageTests.cs b/src/NHibernate.Test/Async/Linq/ByMethod/AverageTests.cs index 4839bde265e..14e4fdf91ef 100644 --- a/src/NHibernate.Test/Async/Linq/ByMethod/AverageTests.cs +++ b/src/NHibernate.Test/Async/Linq/ByMethod/AverageTests.cs @@ -22,29 +22,6 @@ public class AverageTestsAsync : LinqTestCase [Test] public async Task CanGetAverageOfIntegersAsDoubleAsync() { - // TODO 6.0: Enable test for Oracle once nhibernate.oracle.use_binary_floating_point_types is set to true - if (Dialect is Oracle8iDialect) - { - // The point of this test is to verify that LINQ's Average over an - // integer columns yields a non-integer result, even on databases - // where the corresponding avg() will yield a return type equal to - // the input type. This means the LINQ provider must generate HQL - // that cast the input to double inside the call to avg(). This works - // fine on most databases, but Oracle causes trouble. - // - // The dialect maps double to "DOUBLE PRECISION" on Oracle, which - // on Oracle has larger precision than C#'s double. When such - // values are returned, ODP.NET will convert it to .Net decimal, which - // has lower precision and thus causes an overflow exception. - // - // Some argue that this is a flaw in ODP.NET, others have created - // local dialects that use e.g. BINARY_DOUBLE instead, which more - // closely matches C#'s IEEE 745 double, see e.g. HHH-1961 and - // serveral blogs. - - Assert.Ignore("Not supported on Oracle due to casting/overflow issues."); - } - //NH-2429 var average = await (db.Products.AverageAsync(x => x.UnitsOnOrder)); diff --git a/src/NHibernate.Test/Linq/ByMethod/AverageTests.cs b/src/NHibernate.Test/Linq/ByMethod/AverageTests.cs index dfb0890d324..e576587cc01 100644 --- a/src/NHibernate.Test/Linq/ByMethod/AverageTests.cs +++ b/src/NHibernate.Test/Linq/ByMethod/AverageTests.cs @@ -10,29 +10,6 @@ public class AverageTests : LinqTestCase [Test] public void CanGetAverageOfIntegersAsDouble() { - // TODO 6.0: Enable test for Oracle once nhibernate.oracle.use_binary_floating_point_types is set to true - if (Dialect is Oracle8iDialect) - { - // The point of this test is to verify that LINQ's Average over an - // integer columns yields a non-integer result, even on databases - // where the corresponding avg() will yield a return type equal to - // the input type. This means the LINQ provider must generate HQL - // that cast the input to double inside the call to avg(). This works - // fine on most databases, but Oracle causes trouble. - // - // The dialect maps double to "DOUBLE PRECISION" on Oracle, which - // on Oracle has larger precision than C#'s double. When such - // values are returned, ODP.NET will convert it to .Net decimal, which - // has lower precision and thus causes an overflow exception. - // - // Some argue that this is a flaw in ODP.NET, others have created - // local dialects that use e.g. BINARY_DOUBLE instead, which more - // closely matches C#'s IEEE 745 double, see e.g. HHH-1961 and - // serveral blogs. - - Assert.Ignore("Not supported on Oracle due to casting/overflow issues."); - } - //NH-2429 var average = db.Products.Average(x => x.UnitsOnOrder); diff --git a/src/NHibernate/Dialect/Oracle10gDialect.cs b/src/NHibernate/Dialect/Oracle10gDialect.cs index 0495805c4ef..6344f42dcc9 100644 --- a/src/NHibernate/Dialect/Oracle10gDialect.cs +++ b/src/NHibernate/Dialect/Oracle10gDialect.cs @@ -26,12 +26,12 @@ public override JoinFragment CreateOuterJoinFragment() public override void Configure(IDictionary settings) { - base.Configure(settings); - _useBinaryFloatingPointTypes = PropertiesHelper.GetBoolean( Environment.OracleUseBinaryFloatingPointTypes, settings, false); + + base.Configure(settings); } // Avoid registering weighted double type when using binary floating point types