nhibernate-core
nhibernate-core copied to clipboard
NH-2477 - Count after Take return incorect value
rosieks created an issue — :
The following query
issues.Take(30).Count()
return value greater than 30. It should return at most 30.
Fabio Maulo added a comment — :
Test available in the trunk
Ricardo Peres added a comment — :
Confirmed with NH 4.0
I'm trying to resolve this issue, but I think NHibernate generate a correct query (postgres):
select cast(count(*) as int4) as col_0_0_ from Entity entity0_ limit :p0
To work the query should be:
select cast(count(*) as int4) as col_0_0_ from Entity entity0_ where id in (select id from Entity limit 3);
or
select cast(count(*) as int4) as col_0_0_ from ( select Id from Entity limit :p0 ) entity0_
or we can use this code:
var actual = var actual = session.Query<Entity>().Take(3).AsEnumerable().Count();
Related to, indeed nearly duplicated by #1342.