Number Column mapping to nullable boolean Property gets casted wrong in certain expressions

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Wain123
Posts: 12
Joined: Wed 07 Jun 2017 07:25

Number Column mapping to nullable boolean Property gets casted wrong in certain expressions

Post by Wain123 » Thu 08 Jun 2017 10:10

My table "TEST" has a NUMBER(1) property "ACTIVE". It is represented by a nullable boolean property "Active" in my EFCore model. The problem doesn't happen with non-nullable boolean properties.

When I select with a simple condition as follows, it works fine and produces the following correct SQL:

Code: Select all

var x = ctx.Test.Where(z => (bool)z.Active);
Console.WriteLine(x.Count());

Code: Select all

SELECT COUNT(*)
FROM TEST "z"
WHERE "z".ACTIVE = 1
However, when I introduce a boolean && into the condition, the SQL is missing the crucial "= 1", resulting in a ORA-00920 exception.

Code: Select all

x = ctx.Test.Where(z => (bool)z.Active && (bool)z.Active);
Console.WriteLine(x.Count());

Code: Select all

SELECT COUNT(*)
FROM TEST "z"
WHERE "z".ACTIVE AND "z".ACTIVE

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Number Column mapping to nullable boolean Property gets casted wrong in certain expressions

Post by Shalex » Mon 12 Jun 2017 17:06

Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Number Column mapping to nullable boolean Property gets casted wrong in certain expressions

Post by Shalex » Wed 28 Jun 2017 12:02

The bug with generating SQL statements for NUMBER(1) columns mapped to bool properties in EF Core is fixed: viewtopic.php?f=1&t=35592.

Post Reply