Skip to content

Fix Order By for composite property projection in Criteria #2160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 9, 2019

Conversation

bahusoid
Copy link
Member

Fixes #1103

@hazzik
Copy link
Member

hazzik commented Jul 11, 2019

I have another fix in mind. I tried to implement it a while back. The idea is to get rid of StringHelper.RemoveAsAliasesFromSql and instead generate projections without aliases when needed.

@bahusoid
Copy link
Member Author

bahusoid commented Jul 13, 2019

@hazzik Original logic calls GetColumnAliasesUsingProjection for properties where StringHelper.RemoveAsAliasesFromSql is not involved.
So my fix uses GetColumnAliasesUsingProjection for both properties and properties projections (along with Id projection).
StringHelper.RemoveAsAliasesFromSql is called otherwise and I refactored this place to use CriterionUtil.GetColumnNamesUsingProjection. So your suggested fix is unrelated to this PR (but yes it might be useful in other scenarios with composite properties )

@@ -46,6 +46,11 @@ public static class CriterionUtil

internal static SqlString[] GetColumnNamesUsingProjection(IProjection projection, ICriteriaQuery criteriaQuery, ICriteria criteria)
{
if (projection is IPropertyProjection propertyProjection)
Copy link
Member Author

@bahusoid bahusoid Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is actually unrelated to OrderBy fix. But it fixes cases when GetColumnNamesUsingProjection is called for composite property projections (in tests it's covered by .Where(Restrictions.Eq(Projections.Id(), id)))

@hazzik hazzik added the t: Fix label Oct 7, 2019
@hazzik hazzik added this to the 5.3 milestone Oct 7, 2019
@hazzik hazzik merged commit e4d3c96 into nhibernate:master Oct 9, 2019
@hazzik hazzik added the r: Fixed label Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NH-2926 - CriteriaQuery - Unable to sort by composite-id
2 participants