Yitzchok / subsonicproject

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

Patch: Using GetRecordCount() with DISTINCT and OrderBy #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a SqlQuery that uses both Distinct and OrderBy. Then execute
GetRecordCount() on that query. (e.g.
DB.Select().From<Product>().Distinct().InnerJoin<ProductCategory>().OrderAsc("Na
me").GetRecordCount();

What is the expected output? What do you see instead?
Would expect to get record count back, but it throws an exception saying
there is an error near Order By. The problem is that since it is distinct,
the query gets put in a subquery and then the count is taken from that
subquery. However, you cannot have Order By clauses in a subquery. I fixed
it so that if a query is distinct, it builds the subquery without the Order
By clause in it.

What version of the product are you using? On what operating system?
current svn. Win XP. SQL Server 2005

Original issue reported on code.google.com by JonWynv...@gmail.com on 28 Apr 2009 at 5:57

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by canof...@gmail.com on 4 May 2009 at 8:17

GoogleCodeExporter commented 9 years ago
Thanks for the patch! The changes will be reflected in my next check-in...

Original comment by canof...@gmail.com on 4 May 2009 at 8:34

GoogleCodeExporter commented 9 years ago
Patch applied in Revision 522.

Original comment by canof...@gmail.com on 4 May 2009 at 9:06