Skip to content

Commit

Permalink
fix rendering of in (...) lists
Browse files Browse the repository at this point in the history
they are not function calls
  • Loading branch information
gavinking committed May 1, 2023
1 parent 20b1570 commit 783e077
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void visitInListPredicate(InListPredicate inListPredicate) {
if ( inListPredicate.isNegated() ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
renderCommaSeparated( listExpressions );
appendSql( CLOSE_PARENTHESIS );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void visitInListPredicate(InListPredicate inListPredicate) {
if ( inListPredicate.isNegated() ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
renderCommaSeparated( listExpressions );
appendSql( CLOSE_PARENTHESIS );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6770,7 +6770,7 @@ else if ( !supportsRowValueConstructorSyntaxInInList() ) {
if ( inListPredicate.isNegated() ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
String separator = NO_SEPARATOR;
for ( Expression expression : listExpressions ) {
appendSql( separator );
Expand Down Expand Up @@ -6802,7 +6802,7 @@ else if ( !supportsRowValueConstructorSyntaxInInList() ) {
if ( inListPredicate.isNegated() ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
String separator = NO_SEPARATOR;

int bindValueCount = listExpressions.size();
Expand Down Expand Up @@ -6868,7 +6868,7 @@ else if ( bindValueCount < bindValuePaddingCount ) {
if ( inListPredicate.isNegated() ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
separator = NO_SEPARATOR;
itemNumber = 0;
while ( iterator.hasNext() && itemNumber < inExprLimit ) {
Expand Down Expand Up @@ -7421,7 +7421,7 @@ else if ( needsTupleComparisonEmulation( operator ) ) {
if ( operator == ComparisonOperator.NOT_EQUAL ) {
appendSql( " not" );
}
appendSql( " in(" );
appendSql( " in (" );
renderExpressionsAsSubquery( rhsTuple.getExpressions() );
appendSql( CLOSE_PARENTHESIS );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void testSelectChild(SessionFactoryScope scope){
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
}
else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
}

statementInspector.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void testSelectChild(SessionFactoryScope scope) {
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
}
else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
}

statementInspector.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public void testSelectChild(SessionFactoryScope scope) {
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "?" );
}
else {
Assertions.assertThat( statementInspector.getSqlQueries().get( 0 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 0 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
Assertions.assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public void testSelectChild(SessionFactoryScope scope) {
assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "?" );
}
else {
assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in(?,?,?,?,?)" );
assertThat( statementInspector.getSqlQueries().get( 1 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
assertThat( statementInspector.getSqlQueries().get( 2 ) ).containsOnlyOnce( "in (?,?,?,?,?)" );
}

statementInspector.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
assertEquals( 1, ids.size() );
} );

assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in(?,?,?,?,?,?,?,?)" ) );
assertTrue( statementInspector.getSqlQueries().get( 0 ).endsWith( "in (?,?,?,?,?,?,?,?)" ) );
}

@Test
Expand All @@ -102,7 +102,7 @@ public void testInClauseParameterPaddingForExpressions(EntityManagerFactoryScope
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ protected void afterEntityManagerFactoryBuilt(EntityManagerFactoryScope scope) {

@Test
public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
validateInClauseParameterPadding( scope, "in(?)", 1 );
validateInClauseParameterPadding( scope, "in(?,?)", 1, 2 );
validateInClauseParameterPadding( scope, "in(?,?,?,?)", 1, 2, 3 );
validateInClauseParameterPadding( scope, "in(?,?,?,?)", 1, 2, 3, 4 );
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, 7 );
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, 10 );
validateInClauseParameterPadding( scope, "in (?)", 1 );
validateInClauseParameterPadding( scope, "in (?,?)", 1, 2 );
validateInClauseParameterPadding( scope, "in (?,?,?,?)", 1, 2, 3 );
validateInClauseParameterPadding( scope, "in (?,?,?,?)", 1, 2, 3, 4 );
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, 7 );
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, 10 );
}

private void validateInClauseParameterPadding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
);

StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" );
expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" );
}
Expand All @@ -109,7 +109,7 @@ public void testInClauseParameterPaddingToLimit(EntityManagerFactoryScope scope)
);

StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" );
expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) {
expectedInClause.append( ",?" );
}
Expand All @@ -134,12 +134,12 @@ public void testInClauseParameterSplittingAfterLimit(EntityManagerFactoryScope s
);

StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" );
expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) {
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() ) );
}
Expand All @@ -160,12 +160,12 @@ public void testInClauseParameterSplittingAfterLimit2(EntityManagerFactoryScope
);

StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" );
expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) {
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() ) );
}
Expand All @@ -186,17 +186,17 @@ public void testInClauseParameterSplittingAfterLimit3(EntityManagerFactoryScope
);

StringBuilder expectedInClause = new StringBuilder();
expectedInClause.append( "in(?" );
expectedInClause.append( "in (?" );
for ( int i = 1; i < MAX_COUNT; i++ ) {
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++ ) {
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() ) );
Expand Down

0 comments on commit 783e077

Please sign in to comment.