NH-3303 - Refactoring and fixes for custom SQL code
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.SqlQueryReturnProcessorThis class had 2 responsibilities.
- It provided a lookup mechanism for persisters, suffixes and user-defined property result maps, based on raw information read from
INativeSQLQueryReturninstances.- It transformed
INativeSQLQueryReturninstances intoNHibernate.Loader.Custom.IReturninstances for use by theNHibernate.Loader.Custom.CustomLoader.The code related to the first responsibility has been moved into the new
NHibernate.Loader.Custom.Sql.SqlQueryContextclass. The code related to the second responsibility has been integrated into theNHibernate.Loader.Custom.Sql.SqlCustomQueryclass.
NHibernate.Loader.Custom.NonScalarReturnThe return transformation code that originally resided inNHibernate.Loader.Custom.Sql.SqlQueryReturnProcessorand now is part ofNHibernate.Loader.Custom.Sql.SqlCustomQuery, was greatly simplified by removing allIReturnimplementations that extendNonScalarResultand make theNonScalarResultclass a bit smarter.
NHibernate.Loader.Custom.CustomQueryRemoved code that adapted lookup functionality ofNHibernate.Loader.Custom.Sql.SqlQueryReturnProcessorfor use byNHibernate.Loader.Custom.Sql.SqlQueryParserclass. This functionality is now directly provided by the newNHibernate.Loader.Custom.Sql.SqlQueryContextclass.Contains simplified code to transform
INativeSQLQueryReturninstances intoNHibernate.Loader.Custom.IReturninstances. This transformation code originates from the now defunctNHibernate.Loader.Custom.Sql.SqlQueryReturnProcessorclass.
NHibernate.Loader.Custom.CustomLoaderThe constructor code has been simplified a lot because of the reduced number ofIReturnimplementations.
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.