fix rendering of in (...) lists

they are not function calls
This commit is contained in:
Gavin 2023-04-30 18:12:12 +02:00
parent 20b157000c
commit 783e0772e6
10 changed files with 35 additions and 35 deletions

View File

@ -210,7 +210,7 @@ public class DerbyLegacySqlAstTranslator<T extends JdbcOperation> extends Abstra
if ( inListPredicate.isNegated() ) { if ( inListPredicate.isNegated() ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
renderCommaSeparated( listExpressions ); renderCommaSeparated( listExpressions );
appendSql( CLOSE_PARENTHESIS ); appendSql( CLOSE_PARENTHESIS );
} }

View File

@ -238,7 +238,7 @@ public class FirebirdSqlAstTranslator<T extends JdbcOperation> extends AbstractS
if ( inListPredicate.isNegated() ) { if ( inListPredicate.isNegated() ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
renderCommaSeparated( listExpressions ); renderCommaSeparated( listExpressions );
appendSql( CLOSE_PARENTHESIS ); appendSql( CLOSE_PARENTHESIS );
} }

View File

@ -6770,7 +6770,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( inListPredicate.isNegated() ) { if ( inListPredicate.isNegated() ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
String separator = NO_SEPARATOR; String separator = NO_SEPARATOR;
for ( Expression expression : listExpressions ) { for ( Expression expression : listExpressions ) {
appendSql( separator ); appendSql( separator );
@ -6802,7 +6802,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( inListPredicate.isNegated() ) { if ( inListPredicate.isNegated() ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
String separator = NO_SEPARATOR; String separator = NO_SEPARATOR;
int bindValueCount = listExpressions.size(); int bindValueCount = listExpressions.size();
@ -6868,7 +6868,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( inListPredicate.isNegated() ) { if ( inListPredicate.isNegated() ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
separator = NO_SEPARATOR; separator = NO_SEPARATOR;
itemNumber = 0; itemNumber = 0;
while ( iterator.hasNext() && itemNumber < inExprLimit ) { while ( iterator.hasNext() && itemNumber < inExprLimit ) {
@ -7421,7 +7421,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
if ( operator == ComparisonOperator.NOT_EQUAL ) { if ( operator == ComparisonOperator.NOT_EQUAL ) {
appendSql( " not" ); appendSql( " not" );
} }
appendSql( " in(" ); appendSql( " in (" );
renderExpressionsAsSubquery( rhsTuple.getExpressions() ); renderExpressionsAsSubquery( rhsTuple.getExpressions() );
appendSql( CLOSE_PARENTHESIS ); appendSql( CLOSE_PARENTHESIS );
} }

View File

@ -100,8 +100,8 @@ public class BatchAndClassIdTest {
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
} }
else { else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
} }
statementInspector.clear(); statementInspector.clear();

View File

@ -100,8 +100,8 @@ public class BatchAndEmbeddedIdId2Test {
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
} }
else { else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
} }
statementInspector.clear(); statementInspector.clear();

View File

@ -108,8 +108,8 @@ public class BatchAndEmbeddedIdIdAndLazyCollectionTest {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "?" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "?" );
} }
else { else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 0 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 0 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
} }
} }
); );

View File

@ -98,8 +98,8 @@ public class BatchAndEmbeddedIdIdTest {
assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" ); assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
} }
else { else {
assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" ); assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
} }
statementInspector.clear(); statementInspector.clear();

View File

@ -75,7 +75,7 @@ public class InClauseParameterPaddingCriteriaTest {
assertEquals( 1, ids.size() ); assertEquals( 1, ids.size() );
} ); } );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in(?,?,?,?,?,?,?,?)" ) ); assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (?,?,?,?,?,?,?,?)" ) );
} }
@Test @Test
@ -102,7 +102,7 @@ public class InClauseParameterPaddingCriteriaTest {
assertEquals( 1, ids.size() ); assertEquals( 1, ids.size() );
} ); } );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in(d1_0.id,d1_0.id,d1_0.id)" ) ); assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (d1_0.id,d1_0.id,d1_0.id)" ) );
} }
@Entity(name = "Document") @Entity(name = "Document")

View File

@ -54,16 +54,16 @@ public class InClauseParameterPaddingTest {
@Test @Test
public void testInClauseParameterPadding(EntityManagerFactoryScope scope) { public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
validateInClauseParameterPadding( scope, "in(?)", 1 ); validateInClauseParameterPadding( scope, "in (?)", 1 );
validateInClauseParameterPadding( scope, "in(?,?)", 1, 2 ); validateInClauseParameterPadding( scope, "in (?,?)", 1, 2 );
validateInClauseParameterPadding( scope, "in(?,?,?,?)", 1, 2, 3 ); validateInClauseParameterPadding( scope, "in (?,?,?,?)", 1, 2, 3 );
validateInClauseParameterPadding( scope, "in(?,?,?,?)", 1, 2, 3, 4 ); validateInClauseParameterPadding( scope, "in (?,?,?,?)", 1, 2, 3, 4 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8, 9 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8, 9 );
validateInClauseParameterPadding( scope, "in(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ); validateInClauseParameterPadding( scope, "in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
} }
private void validateInClauseParameterPadding( private void validateInClauseParameterPadding(

View File

@ -83,7 +83,7 @@ public class MaxInExpressionParameterPaddingTest {
); );
StringBuilder expectedInClause = new StringBuilder(); StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" ); expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
@ -109,7 +109,7 @@ public class MaxInExpressionParameterPaddingTest {
); );
StringBuilder expectedInClause = new StringBuilder(); StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" ); expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
@ -134,12 +134,12 @@ public class MaxInExpressionParameterPaddingTest {
); );
StringBuilder expectedInClause = new StringBuilder(); StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" ); expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
expectedInClause.append( ")" ); expectedInClause.append( ")" );
expectedInClause.append( " or p1_0.id in(?)" ); expectedInClause.append( " or p1_0.id in (?)" );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) ); assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) );
} }
@ -160,12 +160,12 @@ public class MaxInExpressionParameterPaddingTest {
); );
StringBuilder expectedInClause = new StringBuilder(); StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" ); expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
expectedInClause.append( ")" ); expectedInClause.append( ")" );
expectedInClause.append( " or p1_0.id in(?,?,?,?)" ); expectedInClause.append( " or p1_0.id in (?,?,?,?)" );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) ); assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) );
} }
@ -186,17 +186,17 @@ public class MaxInExpressionParameterPaddingTest {
); );
StringBuilder expectedInClause = new StringBuilder(); StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" ); expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
expectedInClause.append( ")" ); expectedInClause.append( ")" );
expectedInClause.append( " or p1_0.id in(?"); expectedInClause.append( " or p1_0.id in (?");
for ( int i = 1; i < MAX_COUNT; i++ ) { for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" ); expectedInClause.append( ",?" );
} }
expectedInClause.append( ")" ); expectedInClause.append( ")" );
expectedInClause.append( " or p1_0.id in(?,?,?,?)" ); expectedInClause.append( " or p1_0.id in (?,?,?,?)" );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) ); assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( expectedInClause.toString() ) );