Skip to content

Support SQUARE brackets [] around NAMED parameter #27716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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