HHH-17104 More consistent function argument return type checking

This commit is contained in:
Marco Belladelli 2023-08-30 12:43:56 +02:00
parent 8914f5bc65
commit 278ad6a109
1 changed files with 5 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.QueryException;
import org.hibernate.metamodel.mapping.BasicValuedMapping; import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.JdbcMappingContainer; import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.ReturnableType; import org.hibernate.query.ReturnableType;
import org.hibernate.query.sqm.SqmExpressible; import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.SqmPathSource;
@ -108,10 +109,9 @@ public class StandardFunctionReturnTypeResolvers {
ReturnableType<?> impliedType, ReturnableType<?> impliedType,
List<? extends SqmTypedNode<?>> arguments, List<? extends SqmTypedNode<?>> arguments,
TypeConfiguration typeConfiguration) { TypeConfiguration typeConfiguration) {
for ( SqmTypedNode<?> arg : arguments ) { for ( int i = 0; i < arguments.size(); i++ ) {
final SqmExpressible<?> argumentNodeType = arg != null ? getArgumentExpressible( arg ) : null; if ( arguments.get( i ) != null ) {
if ( argumentNodeType instanceof ReturnableType ) { final ReturnableType<?> argType = extractArgumentType( arguments, i + 1 );
ReturnableType<?> argType = (ReturnableType<?>) argumentNodeType;
return isAssignableTo( argType, impliedType ) ? impliedType : argType; return isAssignableTo( argType, impliedType ) ? impliedType : argType;
} }
} }
@ -214,7 +214,7 @@ public class StandardFunctionReturnTypeResolvers {
int position) { int position) {
final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 ); final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 );
final SqmExpressible<?> specifiedArgType = getArgumentExpressible( specifiedArgument ); final SqmExpressible<?> specifiedArgType = getArgumentExpressible( specifiedArgument );
if ( !(specifiedArgType instanceof ReturnableType ) ) { if ( specifiedArgType != null && !(specifiedArgType instanceof ReturnableType ) ) {
throw new QueryException( throw new QueryException(
String.format( String.format(
Locale.ROOT, Locale.ROOT,