AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

CodeSmith.Data.Linq.QueryResultCache.GetHashKey(this IQueryable query) does not always create a Unique Hash Key. #536

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download and Extract Unit Test.rar
2. Open Tracker\Tracker.sln in Visual Studio 2010
3. Update the connection string in the Tracker.Data.QuickTests App.config file.
4. Run the unit tests in Tracker.Data.QuickTests.UnitTest.cs

What is the expected output? What do you see instead?
In the TestMethod_Fails() unit test, the expected output is that 
futureUsersQuery1 and futureUsersQuery2 both pull from the database, and have 
unique values.

Instead the results for the 2nd query are returned from the Cache, even though 
the LINQ queries are different.

What version of the product are you using?
The latest version of PLINQO available at:
http://code.google.com/p/codesmith/

Original issue reported on code.google.com by jamesebu...@gmail.com on 13 Dec 2010 at 10:04

Attachments:

GoogleCodeExporter commented 9 years ago
The attached QueryResultCache.cs file updates the GetHashKey(this IQueryable 
query) method so that the query's parameter values are included when generating 
the Hash Key.  This provides a unique hash in situations where queries having 
different argument values have identical values in their IQueryable.Expression 
property.

Original comment by jamesebu...@gmail.com on 13 Dec 2010 at 10:09

Attachments:

GoogleCodeExporter commented 9 years ago
I was able to reproduce this. I did notice that a few methods were removed from 
this class and could be placed back in.

Paul what do you think?

Original comment by bniemyjski on 14 Dec 2010 at 12:44

GoogleCodeExporter commented 9 years ago
DataContext.GetCommand has a large performance hit.  There seems to be a 
problem in that the expression has both local variables (from your unit test).  
This is only an issue when you have the same query using 2 diff local 
variables.  I'm trying to come up with a better solution. But for now, I think 
we'll just have to take the performance hit.

Original comment by paul.wel...@gmail.com on 27 Dec 2010 at 2:24

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2080.

- fix bug with GetHashKey and Contains not being unique

Original comment by paul.wel...@gmail.com on 29 Dec 2010 at 4:17

GoogleCodeExporter commented 9 years ago
Was able to fix this by handling arrays and lists correctly in the expression 
tree visitor. 

Original comment by paul.wel...@gmail.com on 29 Dec 2010 at 4:18

GoogleCodeExporter commented 9 years ago
I saw the faster fix.  Great job!

Original comment by jamesebu...@gmail.com on 4 Jan 2011 at 7:09