diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/init/ScriptUtils.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/init/ScriptUtils.java index 3e6e99c6c1..3a2c339209 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/init/ScriptUtils.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/init/ScriptUtils.java @@ -85,15 +85,10 @@ public abstract class ScriptUtils { */ public static final String EOF_STATEMENT_SEPARATOR = "^^^ END OF SCRIPT ^^^"; - /** - * Default prefix for single-line comments within SQL scripts: {@code "--"}. - */ - public static final String DEFAULT_COMMENT_PREFIX = "--"; - /** * Default prefixes for single-line comments within SQL scripts: {@code ["--"]}. */ - public static final String[] DEFAULT_COMMENT_PREFIXES = {DEFAULT_COMMENT_PREFIX}; + public static final String[] DEFAULT_COMMENT_PREFIXES = {"--"}; /** * Default start delimiter for block comments within SQL scripts: {@code "/*"}. @@ -109,87 +104,6 @@ public abstract class ScriptUtils { private static final Log logger = LogFactory.getLog(ScriptUtils.class); - /** - * Split an SQL script into separate statements delimited by the provided - * separator character. Each individual statement will be added to the - * provided {@code List}. - *
Within the script, {@value #DEFAULT_COMMENT_PREFIX} will be used as the
- * comment prefix; any text beginning with the comment prefix and extending to
- * the end of the line will be omitted from the output. Similarly,
- * {@value #DEFAULT_BLOCK_COMMENT_START_DELIMITER} and
- * {@value #DEFAULT_BLOCK_COMMENT_END_DELIMITER} will be used as the
- * start and end block comment delimiters: any text enclosed
- * in a block comment will be omitted from the output. In addition, multiple
- * adjacent whitespace characters will be collapsed into a single space.
- * @param script the SQL script
- * @param separator character separating each statement (typically a ';')
- * @param statements the list that will contain the individual statements
- * @throws ScriptException if an error occurred while splitting the SQL script
- * @see #splitSqlScript(String, String, List)
- * @see #splitSqlScript(EncodedResource, String, String, String, String, String, List)
- */
- public static void splitSqlScript(String script, char separator, List Within the script, {@value #DEFAULT_COMMENT_PREFIX} will be used as the
- * comment prefix; any text beginning with the comment prefix and extending to
- * the end of the line will be omitted from the output. Similarly,
- * {@value #DEFAULT_BLOCK_COMMENT_START_DELIMITER} and
- * {@value #DEFAULT_BLOCK_COMMENT_END_DELIMITER} will be used as the
- * start and end block comment delimiters: any text enclosed
- * in a block comment will be omitted from the output. In addition, multiple
- * adjacent whitespace characters will be collapsed into a single space.
- * @param script the SQL script
- * @param separator text separating each statement
- * (typically a ';' or newline character)
- * @param statements the list that will contain the individual statements
- * @throws ScriptException if an error occurred while splitting the SQL script
- * @see #splitSqlScript(String, char, List)
- * @see #splitSqlScript(EncodedResource, String, String, String, String, String, List)
- */
- public static void splitSqlScript(String script, String separator, List Within the script, the provided {@code commentPrefix} will be honored:
- * any text beginning with the comment prefix and extending to the end of the
- * line will be omitted from the output. Similarly, the provided
- * {@code blockCommentStartDelimiter} and {@code blockCommentEndDelimiter}
- * delimiters will be honored: any text enclosed in a block comment will be
- * omitted from the output. In addition, multiple adjacent whitespace characters
- * will be collapsed into a single space.
- * @param resource the resource from which the script was read
- * @param script the SQL script
- * @param separator text separating each statement
- * (typically a ';' or newline character)
- * @param commentPrefix the prefix that identifies SQL line comments
- * (typically "--")
- * @param blockCommentStartDelimiter the start block comment delimiter;
- * never {@code null} or empty
- * @param blockCommentEndDelimiter the end block comment delimiter;
- * never {@code null} or empty
- * @param statements the list that will contain the individual statements
- * @throws ScriptException if an error occurred while splitting the SQL script
- */
- public static void splitSqlScript(@Nullable EncodedResource resource, String script,
- String separator, String commentPrefix, String blockCommentStartDelimiter,
- String blockCommentEndDelimiter, List Lines beginning with the comment prefix are excluded from the
- * results; however, line comments anywhere else — for example, within
- * a statement — will be included in the results.
- * @param lineNumberReader the {@code LineNumberReader} containing the script
- * to be processed
- * @param commentPrefix the prefix that identifies comments in the SQL script
- * (typically "--")
- * @param separator the statement separator in the SQL script (typically ";")
- * @param blockCommentEndDelimiter the end block comment delimiter
- * @return a {@code String} containing the script lines
- * @throws IOException in case of I/O errors
- */
- public static String readScript(LineNumberReader lineNumberReader, @Nullable String commentPrefix,
- @Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException {
-
- String[] commentPrefixes = (commentPrefix != null) ? new String[] { commentPrefix } : null;
- return readScript(lineNumberReader, commentPrefixes, separator, blockCommentEndDelimiter);
- }
-
/**
* Read a script from the provided {@code LineNumberReader}, using the supplied
* comment prefixes and statement separator, and build a {@code String} containing
@@ -392,7 +271,7 @@ public abstract class ScriptUtils {
* @return a {@code String} containing the script lines
* @throws IOException in case of I/O errors
*/
- public static String readScript(LineNumberReader lineNumberReader, @Nullable String[] commentPrefixes,
+ private static String readScript(LineNumberReader lineNumberReader, @Nullable String[] commentPrefixes,
@Nullable String separator, @Nullable String blockCommentEndDelimiter) throws IOException {
String currentStatement = lineNumberReader.readLine();
@@ -435,25 +314,6 @@ public abstract class ScriptUtils {
return false;
}
- /**
- * Determine if the provided SQL script contains the specified delimiter.
- * This method is intended to be used to find the string delimiting each
- * SQL statement — for example, a ';' character.
- * Any occurrence of the delimiter within the script will be ignored if it
- * is within a literal block of text enclosed in single quotes
- * ({@code '}) or double quotes ({@code "}), if it is escaped with a backslash
- * ({@code \}), or if it is within a single-line comment or block comment.
- * @param script the SQL script to search within
- * @param delimiter the statement delimiter to search for
- * @see #DEFAULT_COMMENT_PREFIXES
- * @see #DEFAULT_BLOCK_COMMENT_START_DELIMITER
- * @see #DEFAULT_BLOCK_COMMENT_END_DELIMITER
- */
- public static boolean containsSqlScriptDelimiters(String script, String delimiter) {
- return containsStatementSeparator(null, script, delimiter, DEFAULT_COMMENT_PREFIXES,
- DEFAULT_BLOCK_COMMENT_START_DELIMITER, DEFAULT_BLOCK_COMMENT_END_DELIMITER);
- }
-
/**
* Determine if the provided SQL script contains the specified statement separator.
* This method is intended to be used to find the string separating each
@@ -474,7 +334,7 @@ public abstract class ScriptUtils {
* (typically "*/"
)
* @since 5.3.8
*/
- private static boolean containsStatementSeparator(@Nullable EncodedResource resource, String script,
+ static boolean containsStatementSeparator(@Nullable EncodedResource resource, String script,
String separator, String[] commentPrefixes, String blockCommentStartDelimiter,
String blockCommentEndDelimiter) throws ScriptException {
@@ -547,7 +407,7 @@ public abstract class ScriptUtils {
* @throws ScriptException if an error occurred while executing the SQL script
* @see #executeSqlScript(Connection, EncodedResource, DataBufferFactory, boolean, boolean, String[], String, String, String)
* @see #DEFAULT_STATEMENT_SEPARATOR
- * @see #DEFAULT_COMMENT_PREFIX
+ * @see #DEFAULT_COMMENT_PREFIXES
* @see #DEFAULT_BLOCK_COMMENT_START_DELIMITER
* @see #DEFAULT_BLOCK_COMMENT_END_DELIMITER
* @see org.springframework.r2dbc.connection.ConnectionFactoryUtils#getConnection
@@ -571,7 +431,7 @@ public abstract class ScriptUtils {
* @throws ScriptException if an error occurred while executing the SQL script
* @see #executeSqlScript(Connection, EncodedResource, DataBufferFactory, boolean, boolean, String[], String, String, String)
* @see #DEFAULT_STATEMENT_SEPARATOR
- * @see #DEFAULT_COMMENT_PREFIX
+ * @see #DEFAULT_COMMENT_PREFIXES
* @see #DEFAULT_BLOCK_COMMENT_START_DELIMITER
* @see #DEFAULT_BLOCK_COMMENT_END_DELIMITER
* @see org.springframework.r2dbc.connection.ConnectionFactoryUtils#getConnection
@@ -579,7 +439,7 @@ public abstract class ScriptUtils {
*/
public static Mono