Bug #53611 Problem with Entity Framework using Entity SQL with NOT BETWEEN
Submitted: 12 May 2010 22:30 Modified: 21 May 2010 5:41
Reporter: Junior Gasparotto Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:6.0.4.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Entity SQL, NOT BETWEEN

[12 May 2010 22:30] Junior Gasparotto
Description:
Hello,

I found an error in using the Entity SQL with command 'NOT BETWEEN'

Entity SQL:

---------------------------------

var sql = "SELECT VALUE c FROM OrderSet AS c WHERE field_integer NOT BETWEEN 1 && 20";

var query = context.CreateQuery<Order>(sql, condition.Parameters.ToArray());

MessageBox.Show(query.ToTraceString());

---------------------------------

Output query:

---------------------------------

SELECT ... FROM `order` AS `Extent1` WHERE NOT (`Extent1`.`Id` >= @p0) AND (`Extent1`.`Id` <= @p1)

---------------------------------

See the output, the final query don't contain an groupment negative for the conditional, this code "NOT (A >= @p0) AND (A <= @p1)" leaves negative only first conditional "NOT (A >= @p0)".

Try add more parenthesis in Entity SQL more don't getting effect. The output is same.

var sql = "SELECT VALUE c FROM OrderSet AS c WHERE (field_integer NOT BETWEEN 1 && 20)";

This query has same value, seen an parenthesis  groupment the conditional.

My version is:

-> Visual Studio 2008 SP1
-> Connector 6.0.4.0

Tks

How to repeat:
Hello,

I found an error in using the Entity SQL with command 'NOT BETWEEN'

Entity SQL:

---------------------------------

var sql = "SELECT VALUE c FROM OrderSet AS c WHERE field_integer NOT BETWEEN 1 && 20";

var query = context.CreateQuery<Order>(sql, condition.Parameters.ToArray());

MessageBox.Show(query.ToTraceString());

---------------------------------

Output query:

---------------------------------

SELECT ... FROM `order` AS `Extent1` WHERE NOT (`Extent1`.`Id` >= @p0) AND (`Extent1`.`Id` <= @p1)

---------------------------------

See the output, the final query don't contain an groupment negative for the conditional, this code "NOT (A >= @p0) AND (A <= @p1)" leaves negative only first conditional "NOT (A >= @p0)".

Try add more parenthesis in Entity SQL more don't getting effect. The output is same.

var sql = "SELECT VALUE c FROM OrderSet AS c WHERE (field_integer NOT BETWEEN 1 && 20)";

This query has same value, seen an parenthesis  groupment the conditional.

My version is:

-> Visual Studio 2008 SP1
-> Connector 6.0.4.0

Tks

Suggested fix:
No idea!
[13 May 2010 10:34] Tonci Grgin
Hi Junior and thanks for your report.

EF support in c/NET 6.0 is quite rudimentary. Please upgrade to, at least, 6.2 if not 6.3 and retest.

Waiting on your result.
[21 May 2010 0:36] Junior Gasparotto
Thank Tonca Grgin,

I upgraded to version 6.2.3 and everything went right.

Thank you for your response.
[] S
[21 May 2010 5:41] Tonci Grgin
Junior, glad things work.