Skip to content

Commit cd95331

Browse files
committed
extend test
1 parent f8f447a commit cd95331

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/NHibernate.Test/Async/CompositeId/ClassWithCompositeIdFixture.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public async Task HqlAsync()
242242

243243
//NH-2926 (GH-1103)
244244
[Test]
245-
public async Task QueryOverOrderByIdProjectionDoesntThrowAsync()
245+
public async Task QueryOverOrderByAndWhereWithIdProjectionDoesntThrowAsync()
246246
{
247247
// insert the new objects
248248
using (ISession s = OpenSession())
@@ -262,10 +262,12 @@ public async Task QueryOverOrderByIdProjectionDoesntThrowAsync()
262262

263263
using (ISession s = OpenSession())
264264
{
265-
var results = await (s.QueryOver<ClassWithCompositeId>().Select(Projections.Id()).OrderBy(Projections.Id()).Desc.ListAsync<Id>());
266-
Assert.That(results.Count, Is.EqualTo(2));
265+
var results = await (s.QueryOver<ClassWithCompositeId>()
266+
.Select(Projections.Id())
267+
.Where(Restrictions.Eq(Projections.Id(), id))
268+
.OrderBy(Projections.Id()).Desc.ListAsync<Id>());
269+
Assert.That(results.Count, Is.EqualTo(1));
267270
}
268271
}
269-
270272
}
271273
}

src/NHibernate.Test/CompositeId/ClassWithCompositeIdFixture.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void Hql()
231231

232232
//NH-2926 (GH-1103)
233233
[Test]
234-
public void QueryOverOrderByIdProjectionDoesntThrow()
234+
public void QueryOverOrderByAndWhereWithIdProjectionDoesntThrow()
235235
{
236236
// insert the new objects
237237
using (ISession s = OpenSession())
@@ -251,10 +251,12 @@ public void QueryOverOrderByIdProjectionDoesntThrow()
251251

252252
using (ISession s = OpenSession())
253253
{
254-
var results = s.QueryOver<ClassWithCompositeId>().Select(Projections.Id()).OrderBy(Projections.Id()).Desc.List<Id>();
255-
Assert.That(results.Count, Is.EqualTo(2));
254+
var results = s.QueryOver<ClassWithCompositeId>()
255+
.Select(Projections.Id())
256+
.Where(Restrictions.Eq(Projections.Id(), id))
257+
.OrderBy(Projections.Id()).Desc.List<Id>();
258+
Assert.That(results.Count, Is.EqualTo(1));
256259
}
257260
}
258-
259261
}
260262
}

src/NHibernate/Criterion/Order.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public virtual SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteria
3939
SqlString[] columns = GetColumnsOrAliases(criteria, criteriaQuery);
4040
bool[] toLowerColumns = ignoreCase ? FindStringColumns(criteria, criteriaQuery) : null;
4141

42-
var factory = criteriaQuery.Factory;
4342
var fragment = new SqlStringBuilder();
43+
var factory = criteriaQuery.Factory;
4444
for (int i = 0; i < columns.Length; i++)
4545
{
4646
bool lower = toLowerColumns?[i] == true;

0 commit comments

Comments
 (0)