Page 1 of 1

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

Posted: Thu 08 Jun 2017 10:10
by Wain123
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

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

Posted: Mon 12 Jun 2017 17:06
by Shalex
Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

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

Posted: Wed 28 Jun 2017 12:02
by Shalex
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.