Browse Source

Support SQUARE brackets [] around NAMED parameter

pull/27818/head
Anton Naydenov 3 years ago committed by Juergen Hoeller
parent
commit
86eda279c8
  1. 3
      spring-r2dbc/src/main/java/org/springframework/r2dbc/core/NamedParameterUtils.java
  2. 13
      spring-r2dbc/src/test/java/org/springframework/r2dbc/core/NamedParameterUtilsUnitTests.java

3
spring-r2dbc/src/main/java/org/springframework/r2dbc/core/NamedParameterUtils.java

@ -48,6 +48,7 @@ import org.springframework.util.Assert; @@ -48,6 +48,7 @@ import org.springframework.util.Assert;
* @author Thomas Risberg
* @author Juergen Hoeller
* @author Mark Paluch
* @author Anton Naydenov
* @since 5.3
*/
abstract class NamedParameterUtils {
@ -66,7 +67,7 @@ abstract class NamedParameterUtils { @@ -66,7 +67,7 @@ abstract class NamedParameterUtils {
* Set of characters that qualify as parameter separators,
* indicating that a parameter name in an SQL String has ended.
*/
private static final String PARAMETER_SEPARATORS = "\"':&,;()|=+-*%/\\<>^";
private static final String PARAMETER_SEPARATORS = "\"':&,;()|=+-*%/\\<>^[]";
/**
* An index with separator flags per character code.

13
spring-r2dbc/src/test/java/org/springframework/r2dbc/core/NamedParameterUtilsUnitTests.java

@ -38,6 +38,7 @@ import static org.mockito.Mockito.verify; @@ -38,6 +38,7 @@ import static org.mockito.Mockito.verify;
*
* @author Mark Paluch
* @author Jens Schauder
* @author Anton Naydenov
*/
public class NamedParameterUtilsUnitTests {
@ -274,6 +275,18 @@ public class NamedParameterUtilsUnitTests { @@ -274,6 +275,18 @@ public class NamedParameterUtilsUnitTests {
assertThat(psql2.getParameterNames()).containsExactly("xxx");
}
@Test public void parseSqlStatementWithSquareBracket() {
// given
String sql = "SELECT ARRAY[:ext]";
// when
ParsedSql psql = NamedParameterUtils.parseSqlStatement(sql);
//then
assertThat(psql.getNamedParameterCount()).isEqualTo(1);
assertThat(psql.getParameterNames()).containsExactly("ext");
}
@Test
public void shouldAllowParsingMultipleUseOfParameter() {

Loading…
Cancel
Save