-
Notifications
You must be signed in to change notification settings - Fork 124
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
Bug: Different lambdas in QueryAsync generate the same SQL expression (cache problem) #782
Comments
Thanks for reporting this issue and also for pinpointing the problem. Is this an urgent issue in your side, or has this been rectified by a different approach? Note: We are yet to investigate this. |
It is a bit urgent (has anyone ever said no? 😅) as the only workaround I've found around this problem was to include a custom built repodb dll with the internal lookup cache completely disabled |
Had you tried using the |
I think that would work, but the existing codebase uses the QueryAsync approach. We sadly didn't notice the bug until now. Thank you. |
RepoDB caching mechanism is being driven by the var qg1 = QueryGroup.Parse<MyParSet>(
x => x.IdMy == "idMy" && x.PartMy != 0 && x.VerMy == 0 && x.Country == 1 && x.IsDeleted == false);
var qg2 = QueryGroup.Parse<MyParSet>(
x => x.IdMy == "idMy" && x.PartMy == 0 && x.VerMy != 0 && x.Country == 1 && x.IsDeleted == false);
var equals = qg1 == qg2;
Console.WriteLine(qg1.GetHashCode());
Console.WriteLine(qg2.GetHashCode()); |
The issue can also be replicated this very simplified version of collisions. var qg1 = QueryGroup.Parse<MyParSet>(x => x.PartMy != 0 && x.VerMy == 0);
var qg2 = QueryGroup.Parse<MyParSet>(x => x.PartMy == 0 && x.VerMy != 0); |
The fix is now available at RepoDb v1.12.8-beta4. |
I tried it and now the two hashcodes are indeed different, so it works fine! Thank you! |
Thank you for verifying. |
Bug Description
It seems that two different lambda expression passed to QueryAsync generate the same SQL expression, because the second expression gets wrongly matched to the first one in the CommandTextCache.
Schema and Model:
Bug reproduction:
Comment:
The generated SQL query is for both the lambda this one:
As you see the first and the second lambdas differ from the equality sign between some arguments, but that is not reflected in the cache lookup in the CommandTextCache.cs file, method GetQueryTextAsync,
This lookup is matched the second time, so the generated string for the first lambda is wrongly returned.
Library Version:
Example: RepoDb v1.12.4 and RepoDb.SqlServer v1.1.1, I also tried version 1.1.3 bug the bug was still there.
The text was updated successfully, but these errors were encountered: