Skip to content

Commit

Permalink
Support SQUARE brackets [] around NAMED parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLGVS authored and jhoeller committed Dec 14, 2021
1 parent aeff664 commit 86eda27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @author Thomas Risberg
* @author Juergen Hoeller
* @author Mark Paluch
* @author Anton Naydenov
* @since 5.3
*/
abstract class NamedParameterUtils {
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*
* @author Mark Paluch
* @author Jens Schauder
* @author Anton Naydenov
*/
public class NamedParameterUtilsUnitTests {

Expand Down Expand Up @@ -274,6 +275,18 @@ public void parseSqlStatementWithQuotesAndCommentAfter() {
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() {

Expand Down

0 comments on commit 86eda27

Please sign in to comment.