HHH-18068 fix case-insensitive Order
can't use ordinal column refs inside lower() Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
bea5e4cf3d
commit
8a133ac120
|
@ -659,7 +659,9 @@ public class SqmUtil {
|
|||
// ordering by an element of the select list
|
||||
return new SqmSortSpecification(
|
||||
new SqmAliasedNodeRef( element, builder.getIntegerType(), builder ),
|
||||
order.getDirection()
|
||||
order.getDirection(),
|
||||
order.getNullPrecedence(),
|
||||
order.isCaseInsensitive()
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -4407,21 +4407,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
emulateSortSpecificationNullPrecedence( sortExpression, nullPrecedence );
|
||||
}
|
||||
|
||||
if ( ignoreCase ) {
|
||||
appendSql( dialect.getLowercaseFunction() );
|
||||
appendSql( OPEN_PARENTHESIS );
|
||||
}
|
||||
|
||||
if ( inOverOrWithinGroupClause() ) {
|
||||
resolveAliasedExpression( sortExpression ).accept( this );
|
||||
}
|
||||
else {
|
||||
sortExpression.accept( this );
|
||||
}
|
||||
|
||||
if ( ignoreCase ) {
|
||||
appendSql( CLOSE_PARENTHESIS );
|
||||
}
|
||||
renderSortExpression( sortExpression, ignoreCase );
|
||||
|
||||
if ( sortOrder == SortDirection.DESCENDING ) {
|
||||
appendSql( " desc" );
|
||||
|
@ -4436,6 +4422,24 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
|||
}
|
||||
}
|
||||
|
||||
protected void renderSortExpression(Expression sortExpression, boolean ignoreCase) {
|
||||
if ( ignoreCase ) {
|
||||
appendSql( dialect.getLowercaseFunction() );
|
||||
appendSql( OPEN_PARENTHESIS );
|
||||
}
|
||||
|
||||
if ( inOverOrWithinGroupClause() || ignoreCase ) {
|
||||
resolveAliasedExpression( sortExpression ).accept( this );
|
||||
}
|
||||
else {
|
||||
sortExpression.accept( this );
|
||||
}
|
||||
|
||||
if ( ignoreCase ) {
|
||||
appendSql( CLOSE_PARENTHESIS );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean supportsNullPrecedence() {
|
||||
return dialect.supportsNullPrecedence();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue