List Contains as part of IQuerable fails in Redshift
See original GitHub issueIt appears that a query with a list that should generate an In or Any statement is failing. I am using redshift but I don;t even think it hits the server. It is failing inside the compiler. The error I get is : ‘22P03: invalid array flags’
Example EF IQueryable statement:
public async Task<List<Domain.Entities.Security>> GetSecuritiesByCodes(List<int> securityIds)
{
var securityModels = await _context.Securities
.Where(w => w.IsDeleted == false && securityIds.Contains(w.Id))
.ToListAsync();
return securityModels;
}
SQL generated by EF IQueryable statement
SELECT s."Id", s."Code", s."IsDeleted", s."Name", s."PrimaryBenchmarkProductId", s."SecurityTypeId"
FROM performance."Securities" AS s
WHERE NOT (s."IsDeleted") AND s."Id" = ANY ($1)
I can’t determine what $1 gets compiled as but it doesn’t seem to hit the server. If you substitute $1 with ‘{1,2,3,4,5,6,7,8,9,10,11}’ then the query works fine and return the right results.
Here is a snapshot of the params.
Redshift Table Definition
CREATE TABLE performance.securities (
id int4 NOT NULL,
code varchar(256) NOT NULL,
"name" varchar(256) NULL,
securitytypeid int4 NULL,
primarybenchmarkproductid int4 NULL,
isdeleted bool NOT NULL DEFAULT 0
)
Connection String “Host=.ap-southeast-2.redshift.amazonaws.com;Port=5439;Database=dev;Username=awsuser;Password=;Server Compatibility Mode=Redshift;”,
I am using EF core 5.0.2 and Npgssql 5.0.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (9 by maintainers)
@sep2 that is not what I’m seeing with the code sample below: without Redshift, the provider generates an ANY expression from the LINQ query. Please open a new issue with a runnable code sample which demonstrates the issue.
Attempted repro
@roji I can confirm that the issue has been fixed, although the fix is quite a heavy one as it involves upgrading to dotnet5, upgrading all the ef core resources to ef core 6 daily build versions, but that should all resolve itself over time. Thanks again for your help with this.
Matt