Skip to content

Fix missing subclass discriminator in ON clause for entity joins #2600

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 3 commits into from
Nov 13, 2020

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Nov 9, 2020

This issue affects both Criteria/QueryOver and Hql/Linq Query API. While it's regression only for LINQ case I made fix also for Criteria (as fix is quite simple).

Fixes #2599 (complete fix for #2463)

@bahusoid bahusoid changed the base branch from master to 5.3.x November 9, 2020 11:13
@bahusoid bahusoid changed the title Fix missing subclass discriminator in ON clause Fix missing subclass discriminator in ON clause fore entity joins Nov 9, 2020
@bahusoid bahusoid changed the title Fix missing subclass discriminator in ON clause fore entity joins Fix missing subclass discriminator in ON clause for entity joins Nov 9, 2020
@fredericDelaporte fredericDelaporte added this to the 5.3.5 milestone Nov 9, 2020
@bahusoid bahusoid linked an issue Nov 10, 2020 that may be closed by this pull request
@hazzik hazzik merged commit 158baa5 into nhibernate:5.3.x Nov 13, 2020
@fredericDelaporte
Copy link
Member

Should we wait a bit in case of other issues waiting to be reported, or release this soon, like on next Sunday?

@hazzik
Copy link
Member

hazzik commented Nov 13, 2020

I would say don't wait.

bahusoid added a commit to bahusoid/nhibernate-core that referenced this pull request Nov 14, 2020
@bahusoid
Copy link
Member Author

Just in case of troubles with resolving conflicts when merge to master:
https://github.com/bahusoid/nhibernate-core/tree/GH2599UP

bahusoid added a commit to bahusoid/nhibernate-core that referenced this pull request Aug 10, 2021
Comment on lines +196 to 200
// Apply filters for entity joins and Many-To-One association
var enabledForManyToOne = FilterHelper.GetEnabledForManyToOne(enabledFilters);
condition = new SqlString(string.IsNullOrEmpty(on) && enabledForManyToOne.Count > 0
condition = new SqlString(string.IsNullOrEmpty(on) && (ForceFilter || enabledForManyToOne.Count > 0)
? join.Joinable.FilterFragment(join.Alias, enabledForManyToOne)
: on);
Copy link
Member

Choose a reason for hiding this comment

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

@bahusoid,
I think we have missed something here, which could have fixed #3046 if done similarly in other places having that ForceFilter: when true, shouldn't it filter on all enabled filters, not just on many-to-one enabled ones ?

					// Apply filters for entity joins and Many-To-One association
					var enabledFiltersForJoin = ForceFilter ? enabledFilters : FilterHelper.GetEnabledForManyToOne(enabledFilters);
					condition = new SqlString(string.IsNullOrEmpty(on) && (enabledFiltersForJoin.Count > 0)
					            	? join.Joinable.FilterFragment(join.Alias, enabledFiltersForJoin)
					            	: on);

But it may not be enough, because the on variable construction does exclude filters not enabled for many-to-one too.

Comment on lines +855 to 858
// Apply filters for entity joins and Many-To-One associations
if (oj.ForceFilter || enabledFiltersForManyToOne.Count > 0)
{
string manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFiltersForManyToOne);
Copy link
Member

Choose a reason for hiding this comment

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

Similarly:

					// Apply filters for entity joins and Many-To-One associations
					var enabledFiltersForJoin = oj.ForceFilter ? enabledFilters : enabledFiltersForManyToOne;
					if (oj.ForceFilter || enabledFiltersForJoin.Count > 0)
					{
						string manyToOneFilterFragment = oj.Joinable.FilterFragment(oj.RHSAlias, enabledFiltersForJoin);

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.

WrongClassException in Linq query
3 participants