Skip to content

Fix ConditionalProjection GetType from outer query #2455

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 8 commits into from
Sep 12, 2020

Conversation

delta-emil
Copy link
Contributor

This should fix #2454.

The AsyncGenerator was failing for me (I'll open another issue about that) from the build menu, so I wrote the async version of the test by hand.

@fredericDelaporte
Copy link
Member

About async generation, you may have maca88/AsyncGenerator#150 issue, see its discussion for a workaround.

@delta-emil
Copy link
Contributor Author

Thank you, @fredericDelaporte, that did allow the AsyncGenerator to run, and it did make a few additional things Async that I'd missed. You should really get that committed.

I also made the test exclude MsSqlCe by SupportsScalarSubSelects of the dialect.

Can you tell me if I need to fix the CodeFactor check's SA1402 violation? It seems like all test cases use the pattern of putting all entity classes in one file.

@bahusoid
Copy link
Member

Note for future. Looking at stack trace:

AbstractEntityPersister.ToType(String propertyName) line 2065
CriteriaQueryTranslator.GetType(ICriteria subcriteria, String propertyName) line 810
PropertyProjection.GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) line 50
ConditionalProjection.GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) line 56
SimpleProjection.GetColumnCount(ICriteria criteria, ICriteriaQuery criteriaQuery) line 79
SimpleProjection.GetColumnAliases(Int32 position, ICriteria criteria, ICriteriaQuery criteriaQuery) line 41
ConditionalProjection.ToSqlString(ICriteria criteria, Int32 position, ICriteriaQuery criteriaQuery) line 50

All those calls to generate single alias "y" + position + "_" seems excessive.

@delta-emil
Copy link
Contributor Author

Note for future. Looking at stack trace:

AbstractEntityPersister.ToType(String propertyName) line 2065
CriteriaQueryTranslator.GetType(ICriteria subcriteria, String propertyName) line 810
PropertyProjection.GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) line 50
ConditionalProjection.GetTypes(ICriteria criteria, ICriteriaQuery criteriaQuery) line 56
SimpleProjection.GetColumnCount(ICriteria criteria, ICriteriaQuery criteriaQuery) line 79
SimpleProjection.GetColumnAliases(Int32 position, ICriteria criteria, ICriteriaQuery criteriaQuery) line 41
ConditionalProjection.ToSqlString(ICriteria criteria, Int32 position, ICriteriaQuery criteriaQuery) line 50

All those calls to generate single alias "y" + position + "_" seems excessive.

It was much simpler before it was changed in 1775cc2, which references https://nhibernate.jira.com/browse/NH-3644. The same change also caused #1180. The change seems to be in the direction of supporting multiple aliases for composite columns, but then the code still just only takes the first element of the returned array. Maybe we can move back to the much simpler callGetColumnAliases(position) in ConditionalProjection's ToSqlString?

@bahusoid
Copy link
Member

bahusoid commented Jul 28, 2020

The change seems to be in the direction of supporting multiple aliases for composite columns, but then the code still just only takes the first element of the returned array. Maybe we can move back to the much simpler callGetColumnAliases(position) in ConditionalProjection's ToSqlString

Yeah I got where those changes come from. Only I think all places should be changed back where replacement was done to analogue of SimpleProjection.GetColumnAliases(position, criteria, criteriaQuery)[0] back to SimpleProjection.GetColumnAliases(position)[0]

@delta-emil
Copy link
Contributor Author

But discussion of future plans aside, I still think the change submitted here is a correct thing. So how I move it forward?

  • Do I need to fix the CodeFactor SA1402 violation in the test code (despite that breaking the pattern set by the other tests)?
  • Shall I update the branch to the current master?
  • Or should I just leave it alone for the moment, until someone has the chance to review the change?

@bahusoid
Copy link
Member

I still think the change submitted here is a correct thing.

Yes. I agree. I didn't do it in first place (when TryGetType was introduced to fix similar issue #1312) as I was lazy to compose test case when it's needed and didn't want to change behavior without test case. And I suspect that GetColumn method would need to be changed in similar way too.

Do I need to fix the CodeFactor SA1402

It's fine as is by me. But I guess better to fix it just to make everyone happy.

Shall I update the branch to the current master?

You can force push it if you want to make it look clean. But don't sweat on it (as long GitHub's Update Branch works without conflicts)

bahusoid
bahusoid previously approved these changes Sep 9, 2020
hazzik
hazzik previously approved these changes Sep 10, 2020
@hazzik hazzik added the t: Fix label Sep 10, 2020
@hazzik hazzik added this to the next minor milestone Sep 10, 2020
@hazzik hazzik merged commit b21a978 into nhibernate:master Sep 12, 2020
@hazzik hazzik changed the title #2454 fix ConditionalProjection GetType from outer query Fix ConditionalProjection GetType from outer query Sep 12, 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.

ConditionalProjection containing the correlation to outer query fails to determine projection type
4 participants