directus / directus/directus

MSSQL Query with more than 2100 parameter leads to a sql exception

Open
#21,993 4 comments 1 reaction 0 assignees View on GitHub
Bug CRUD Engine MS SQL Server
Dominant language
TypeScript
Stars
37.9k
Forks
4.9k
Avg merge
3d 21h
Merged PRs (30d)
36

Description

### Describe the Bug

I have a collection with an 1:n relation to another collection. Something like Authors to Books.
If i have an author with more than 2100 books, its not possible to open the list of all authors.
The query ends with:
```
{
"errors": [
{
"message": {
"code": "EREQUEST",
"number": 8003,
"state": 1,
"class": 16,
"serverName": "a8ab61c49291",
"procName": "",
"lineNumber": 1
},
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
}
}
]
}
```

The executed sql was:
``` sql
select top (@p0) [collection].[id], [collection].[a] .. from [[collection] where [collection].[foreignKey] in (@p1, @p2,........)
order by [collection].[id] asc
```

The SQL Result is:
```
The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
```

If i open the collection details of the author collection, everything works fine. The issue occurs only in the collection list overview.

### To Reproduce

Create a relationship with more than 2100 childs.

### Directus Version

10.10.4

### Hosting Strategy

Self-Hosted (Docker Image)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.