Support SQUARE brackets [] around NAMED parameter
This commit is contained in:
parent
aeff664cf9
commit
86eda279c8
|
@ -48,6 +48,7 @@ import org.springframework.util.Assert;
|
||||||
* @author Thomas Risberg
|
* @author Thomas Risberg
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Anton Naydenov
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
abstract class NamedParameterUtils {
|
abstract class NamedParameterUtils {
|
||||||
|
@ -66,7 +67,7 @@ abstract class NamedParameterUtils {
|
||||||
* Set of characters that qualify as parameter separators,
|
* Set of characters that qualify as parameter separators,
|
||||||
* indicating that a parameter name in an SQL String has ended.
|
* 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.
|
* An index with separator flags per character code.
|
||||||
|
|
|
@ -38,6 +38,7 @@ import static org.mockito.Mockito.verify;
|
||||||
*
|
*
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Jens Schauder
|
* @author Jens Schauder
|
||||||
|
* @author Anton Naydenov
|
||||||
*/
|
*/
|
||||||
public class NamedParameterUtilsUnitTests {
|
public class NamedParameterUtilsUnitTests {
|
||||||
|
|
||||||
|
@ -274,6 +275,18 @@ public class NamedParameterUtilsUnitTests {
|
||||||
assertThat(psql2.getParameterNames()).containsExactly("xxx");
|
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
|
@Test
|
||||||
public void shouldAllowParsingMultipleUseOfParameter() {
|
public void shouldAllowParsingMultipleUseOfParameter() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue