Skip to content

Commit

Permalink
Fix Oracle binary floating point setting
Browse files Browse the repository at this point in the history
  • Loading branch information
maca88 authored and fredericDelaporte committed May 31, 2020
1 parent 50fa0d8 commit da13b9f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 48 deletions.
23 changes: 0 additions & 23 deletions src/NHibernate.Test/Async/Linq/ByMethod/AverageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
23 changes: 0 additions & 23 deletions src/NHibernate.Test/Linq/ByMethod/AverageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/NHibernate/Dialect/Oracle10gDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public override JoinFragment CreateOuterJoinFragment()

public override void Configure(IDictionary<string, string> 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
Expand Down

0 comments on commit da13b9f

Please sign in to comment.