SQLOutput prints endDelimiter regexes

Description

SQLFileChange and StringUtils both suggests that complex regex for endDelimiter are supportted. Yet,
LoggingExecutor wrongly assumes that his endDelimiter is a valid delimiter string for databases
other than MSSQLDatabase, SybaseDatabase and SybaseASADatabase.

This hinders the usefulness of the following configuration: <sqlFile> applied to Oracle through UpdateSQL.

Excerpt from LoggingExecutor.java

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 private void outputStatement(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException { try { if (SqlGeneratorFactory.getInstance().generateStatementsVolatile(sql, database)) { throw new DatabaseException(sql.getClass().getSimpleName()+" requires access to up to date database metadata which is not available in SQL output mode"); } for (String statement : applyVisitors(sql, sqlVisitors)) { if (statement == null) { continue; } output.write(statement); if (database instanceof MSSQLDatabase || database instanceof SybaseDatabase || database instanceof SybaseASADatabase) { output.write(StreamUtil.getLineSeparator()); output.write("GO"); // } else if (database instanceof OracleDatabase) { // output.write(StreamUtil.getLineSeparator()); // output.write("/"); } else { String endDelimiter = ";"; if (sql instanceof RawSqlStatement) { endDelimiter = ((RawSqlStatement) sql).getEndDelimiter(); } if (!statement.endsWith(endDelimiter)) { output.write(endDelimiter); } } output.write(StreamUtil.getLineSeparator()); output.write(StreamUtil.getLineSeparator()); } } catch (IOException e) { throw new DatabaseException(e); } }

Excerpt from StringUtils.java

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 /** * Splits a (possible) multi-line SQL statement along ;'s and "go"'s. */ public static String[] splitSQL(String multiLineSQL, String endDelimiter) { if (endDelimiter == null) { endDelimiter = ";\\s*\n|;$|\n[gG][oO]\\s*\n|\n[Gg][oO]\\s*$"; } else { if (endDelimiter.equalsIgnoreCase("go")) { endDelimiter = "\n[gG][oO]\\s*\n|\n[Gg][oO]\\s*$"; } } String[] initialSplit = multiLineSQL.split(endDelimiter); List<String> strings = new ArrayList<String>(); for (String anInitialSplit : initialSplit) { String singleLineSQL = anInitialSplit.trim(); if (singleLineSQL.length() > 0) { strings.add(singleLineSQL); } } return strings.toArray(new String[strings.size()]); }

The issue touches the same problem, but for SybaseDatabase.

Environment

Windows, Oracle 11

Status

Assignee

Unassigned

Reporter

Thiago Kronig

Labels

None

Components

Fix versions

Affects versions

3.1.1

Priority

Major