Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF.Constant(keys) usage in BatchDataLoader does not work correctly (MSSQL EF8/9) #7769

Closed
kresimirlesic opened this issue Nov 26, 2024 · 1 comment

Comments

@kresimirlesic
Copy link

kresimirlesic commented Nov 26, 2024

Product

Hot Chocolate

Version

14.1.0

Link to minimal reproduction

https://gist.github.com/kresimirlesic/32e39360f8ec10b6285f58721ec7d69c

Steps to reproduce

Invoke BatchDataLoader multiple times, passing down different values of keys.

What is expected?

Results from the database should match accordingly to the passed keys.

What is actually happening?

Incorrect results are being returned.
The constructed SQL contains keys in the query from the first BatchDataLoader invocation.

Relevant log output

Additional context

I did a bit of investigation on a side and the issue boils down to how HC reuses a list to populate the keys under the hood.
That causes a weird interaction with EF.

With list reusal:
Image

Without list reusal:
Image

@michaelstaib
Copy link
Member

This is as designed. We by default rent a list for keys in DataLoader. If you want to use it in combination with EF.Constant you need to allocate a list that you can pass on by doing a ToList or ToArray on the keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants