Substring in combination with Array results in wrong SQL (Oracle)

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Flo
Posts: 8
Joined: Mon 22 May 2017 08:49

Substring in combination with Array results in wrong SQL (Oracle)

Post by Flo » Tue 26 Jul 2022 11:27

If you use a substring in combination with an array (in c#) devart creates wrong SQL.
Here are some (pseudo) code to reproduce:

Code: Select all

var array = new string[] { "23", "71" };
var query = this.DataContext.MyState.Where(x => array.Contains(x.Value.Substring(0, 2)));
var q = query.ToQueryString();
First call is correct, it generates:

Code: Select all

SELECT "f".ID, "f".VALUE
FROM MYSTATE "f"
WHERE SUBSTR("f".VALUE, 0 + 1, 2) IN ('23', '71')
but second looks like:

Code: Select all

SELECT "f".ID, "f".VALUE
FROM MYSTATE "f"
WHERE SUBSTR("f".VALUE, (0 + 1) + 1, 2) IN ('23', '71')
and the next one will be:

Code: Select all

SELECT "f".ID, "f".VALUE
FROM MYSTATE "f"
WHERE SUBSTR("f".VALUE, (((0 + 1) + 1) + 1) + 1, 2) IN ('23', '71')
and so forth.
Looks like an static variable which get increased every call.
Version was Devart.Data.Oracle.EFCore Version=9.16.1434, also the Version 10 has the same bug.

Flo
Posts: 8
Joined: Mon 22 May 2017 08:49

Re: Substring in combination with Array results in wrong SQL (Oracle)

Post by Flo » Wed 31 Aug 2022 06:16

Hello @devart,

have you check the issue and can confirm it?
When will it be fixed?

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

Re: Substring in combination with Array results in wrong SQL (Oracle)

Post by Shalex » Wed 05 Oct 2022 12:36

Thank you for your report. We have reproduced the described behavior and will notify you about the results of our investigation.

Post Reply