Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Oracle binary floating point setting #2402

Merged
merged 1 commit into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method RegisterFloatingPointTypeMappings is called inside base.Configure, so the field must be set before calling it.

}

// Avoid registering weighted double type when using binary floating point types
Expand Down