Skip to content

Regression for filters on entity joins with many-to-one disabled #3046

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

Closed
manuelspezzani opened this issue Apr 23, 2022 · 2 comments
Closed

Comments

@manuelspezzani
Copy link

I'm trying to migrate my project from v5.2.7 to the latest 5.3.x version but apparently I've hit a potential regression / breaking change on how filters are applied.

My filter is defined like this:

            configuration.AddFilterDefinition(new FilterDefinition(
                LabelFilterName,
                "Label IN ('A', 'B', 'C')",
                new Dictionary<string, IType>(),
                false));

On "simple" queries it is applied as expected, but on a more complex one it is not:

            var query = from b in session.Query<OtherTable>() 
                        join jta in session.Query<JoinTable>() on b.Id equals jta.OtherTableId
                        join ft in session.Query<FilteredTable>() on jta.FilteredTableId equals ft.Id
                        select new
                        {
                            jta.FilteredTableId,
                            ft.Label
                        };

I've attached a small repro to demonstrate the issue: on 5.2.7 both unit tests are green, but on 5.3.11 one of them fails.

repro.zip

@fredericDelaporte
Copy link
Member

It looks like #2549, excepted #2549 has been fixed in 5.3.4. The test provided here, even simplified to a single join, fails from 5.3.0 to 5.3.11.

There is one difference between #2549 tests (in PR #2550) and yours: your filter is explicitly disabled for many-to-one relations, while the default (with filter-def in hbm mappings, used by #2550) is to have it enabled. If you switch the last argument to FilterDefinition constructor to true instead of false, your tests then all pass with latest NHibernate versions.

So, for some reason, filters are no more enabled on entities fetched through arbitrary joins if the filter useManyToOne setting is disabled. This change has occurred in 5.3.0. I have not investigated what has caused this change, so I cannot tell yet if it has to be considered a regression or an undocumented breaking change.

fredericDelaporte added a commit to fredericDelaporte/nhibernate-core that referenced this issue Apr 24, 2022
@fredericDelaporte fredericDelaporte added this to the 5.3.12 milestone Apr 28, 2022
@fredericDelaporte fredericDelaporte changed the title Possible regression on how filters are applied to LINQ queries Regression for filters on entity joins with many-to-one disabled Apr 28, 2022
@fredericDelaporte
Copy link
Member

Fixed by #3048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants