Skip to content
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

NH-3303 - Refactoring and fixes for custom SQL code #1945

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Dec 23, 2018

This is a rebase with some minimal clean-up of #360.
Edits from maintainers are rejected on #360, so working on it requires a new PR.

As stated in the original PR, #161, here are the rational of this PR:

Major refactoring of custom SQL code to reduce code duplication and simplify maintenance and bug fixes.

The following classes have been affected mostly:

  • NHibernate.Loader.Custom.Sql.SqlQueryReturnProcessor
    This class had 2 responsibilities.

    1. It provided a lookup mechanism for persisters, suffixes and user-defined property result maps, based on raw information read from INativeSQLQueryReturn instances.
    2. It transformed INativeSQLQueryReturn instances into NHibernate.Loader.Custom.IReturn instances for use by the NHibernate.Loader.Custom.CustomLoader.

    The code related to the first responsibility has been moved into the new NHibernate.Loader.Custom.Sql.SqlQueryContext class. The code related to the second responsibility has been integrated into the NHibernate.Loader.Custom.Sql.SqlCustomQuery class.

  • NHibernate.Loader.Custom.NonScalarReturn
    The return transformation code that originally resided in NHibernate.Loader.Custom.Sql.SqlQueryReturnProcessor and now is part of NHibernate.Loader.Custom.Sql.SqlCustomQuery, was greatly simplified by removing all IReturn implementations that extend NonScalarResult and make the NonScalarResult class a bit smarter.

  • NHibernate.Loader.Custom.CustomQuery
    Removed code that adapted lookup functionality of NHibernate.Loader.Custom.Sql.SqlQueryReturnProcessor for use by NHibernate.Loader.Custom.Sql.SqlQueryParser class. This functionality is now directly provided by the new NHibernate.Loader.Custom.Sql.SqlQueryContext class.

    Contains simplified code to transform INativeSQLQueryReturn instances into NHibernate.Loader.Custom.IReturn instances. This transformation code originates from the now defunct NHibernate.Loader.Custom.Sql.SqlQueryReturnProcessor class.

  • NHibernate.Loader.Custom.CustomLoader
    The constructor code has been simplified a lot because of the reduced number of IReturn implementations.

That is a binary breaking change, so it could go only in 6.0. It may be changed for being no more binary breaking, but it will likely imply to keep a lot of the removed code.

If merged, it should be manually squashed before, in order to preserve @ggeurts as the main author.

Replaces #360.

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

Successfully merging this pull request may close these issues.

None yet

2 participants