HHH-10383 : IN parameter is not enclosed in parenthesis
This commit is contained in:
parent
cb0729b59f
commit
4c6941190a
|
@ -173,11 +173,17 @@ public final class StringHelper {
|
|||
!wholeWords
|
||||
|| afterPlaceholder.length() == 0
|
||||
|| !Character.isJavaIdentifierPart( afterPlaceholder.charAt( 0 ) );
|
||||
// We only need to check the left param to determine if the placeholder is already
|
||||
// enclosed in parentheses (HHH-10383)
|
||||
// Examples:
|
||||
// 1) "... IN (?1", we assume that "?1" does not need to be enclosed because there
|
||||
// there is already a right-parenthesis; we assume there will be a matching right-parenthesis.
|
||||
// 2) "... IN ?1", we assume that "?1" needs to be enclosed in parentheses, because there
|
||||
// is no left-parenthesis.
|
||||
boolean encloseInParens =
|
||||
actuallyReplace
|
||||
&& encloseInParensIfNecessary
|
||||
&& !( getLastNonWhitespaceCharacter( beforePlaceholder ) == '(' )
|
||||
&& !( getFirstNonWhitespaceCharacter( afterPlaceholder ) == ')' );
|
||||
&& !( getLastNonWhitespaceCharacter( beforePlaceholder ) == '(' );
|
||||
StringBuilder buf = new StringBuilder( beforePlaceholder );
|
||||
if ( encloseInParens ) {
|
||||
buf.append( '(' );
|
||||
|
|
|
@ -1416,6 +1416,30 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
|||
.setParameterList( "1", params )
|
||||
.list();
|
||||
|
||||
s.createQuery( "from Human where nickname = ?1 and ( name.first = ?2 or name.last in (?3) )" )
|
||||
.setParameter( "1", "Yogster" )
|
||||
.setParameter( "2", "Yogi" )
|
||||
.setParameterList( "3", params )
|
||||
.list();
|
||||
|
||||
s.createQuery( "from Human where nickname = ?1 and ( name.first = ?2 or name.last in ?3 )" )
|
||||
.setParameter( "1", "Yogster" )
|
||||
.setParameter( "2", "Yogi" )
|
||||
.setParameterList( "3", params )
|
||||
.list();
|
||||
|
||||
s.createQuery( "from Human where nickname = ?1 or ( name.first = ?2 and name.last in (?3) )" )
|
||||
.setParameter( "1", "Yogster" )
|
||||
.setParameter( "2", "Yogi" )
|
||||
.setParameterList( "3", params )
|
||||
.list();
|
||||
|
||||
s.createQuery( "from Human where nickname = ?1 or ( name.first = ?2 and name.last in ?3 )" )
|
||||
.setParameter( "1", "Yogster" )
|
||||
.setParameter( "2", "Yogi" )
|
||||
.setParameterList( "3", params )
|
||||
.list();
|
||||
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue