Skip to content

Support for criteria aliases in SqlProjection and SQLCriterion #2383

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 7 commits into from
May 26, 2020

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented May 16, 2020

Fixes #896

This is an alternative approach to #2358. Here we replace all registered aliases without need of explicitly registering them.

Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

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

I have reviewed both again, and I think this one is better.

@hazzik
Copy link
Member Author

hazzik commented May 17, 2020

At least in SQL, it is supported to have a subquery alias hiding an outer query alias. If it is also supported with Criteria, then this code needs to be adjusted.

Yes, this is supported. For the actual SQL it will generate unique aliases.

internal IDictionary<string, string> GetCriteriaSQLAliasMap()
{
var result = outerQueryTranslator != null
? new Dictionary<string, string>(outerQueryTranslator.GetCriteriaSQLAliasMap())
Copy link
Member Author

Choose a reason for hiding this comment

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

Creating a new dictionary because outerQueryTranslator.GetCriteriaSQLAliasMap() could be an EmptyDictionary which is read-only.

@hazzik hazzik requested a review from fredericDelaporte May 17, 2020 22:35
Encapsulate logic of rendering SQL aliases into CriteriaQueryTranslator
@fredericDelaporte fredericDelaporte added this to the 5.3 milestone May 24, 2020
@hazzik hazzik merged commit 14fef3f into nhibernate:master May 26, 2020
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-1432 - Expression.Sql should support aliases other than {alias}
2 participants