Thanks you Julian for the effort.
Perhaps the DISTINCT should be replaced by a "GROUP BY"...
Can you spent more time and try something like this ?
orderByClause = originalQuery.GetOrderByOrUse("ORDER BY CURRENT_TIMESTAMP");
// Use the sequence of columns selected in the SELECT to create a group by
clause (removing the alias of the column)
queryToPaginate = originalQuery.RemoveDistinctAndAddGroupBy();
// Add, as first column of the select clause: ROW_NUMBER() OVER
(orderByClause) as _nhRowNumber_,
queryToPaginate
= queryToPaginate.InsertRowNumberInSelectClause(orderByClause);
return
WITH finalQuery AS (queryToPaginate) SELECT * FROM finalQuery WHERE
_nhRowNumber_ BETWEEN pSkip AND (:pSkip + :pTake)
hmmmm perhaps it is too dangerous for the Release Candidate (well... perhaps
even the patch for NH-2214 is something dangerous).
Hopefully we will have the help of a bunch of pioneers testing the new
pagination, whatever it will be, in some real scenarios.
On Tue, Jun 21, 2011 at 1:14 PM, Julian Maughan <[email protected]>wrote:
> Fabio, could you review my proposed patch for NH-2214 for inclusion in 3.2?
> It passes all tests (of course). Please let me know if you have any
> questions about it. I think it is actually fairly low risk, as it caters for
> a particular case where DISTINCT is used in a paged query. This is done with
> an alternate query, and non-distinct queries are still done as before.
>
> The changes toDialectTest.MsSql2005DialectFixture.GetLimitString were
> required because the SQL output by the dialect is different. Also, the SQL
> generated by the previous code was in fact incorrect, and exhibited the
> exact problem described in NH-2214 - applying distinct on a row containing
> the ROW_NUMBER() OVER (ORDER BY ...)
>
> Thanks
> Julian
>
> Thanks.
>
>
> On 20 June 2011 20:12, Fabio Maulo <[email protected]> wrote:
>
>> Hi.
>> NH3.2.0Beta2 was released.
>> The next will be a ReleaseCandidate so, please, stop breaking change and
>> stuff like that.
>> Thanks.
>>
>> --
>> Fabio Maulo
>>
>>
>
--
Fabio Maulo