Skip to content

Commit

Permalink
0002444: DbExport fails when using "MSSQL" Type.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichalek committed Nov 12, 2015
1 parent 4b367f5 commit 56647fe
Showing 1 changed file with 13 additions and 6 deletions.
Expand Up @@ -405,6 +405,13 @@ public int getMaxRows() {
return maxRows;
}

protected String getDatabaseName() {
if (compatible == Compatible.MSSQL) {
compatible = Compatible.MSSQL2000;
}
return compatible.toString().toLowerCase();
}

class WriterWrapper {
final private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Expand Down Expand Up @@ -459,6 +466,8 @@ protected void startTable(Table table) {
}
startedWriting = true;
}

String databaseName = getDatabaseName();

if (format == Format.CSV && csvWriter == null) {
csvWriter = new CsvWriter(writer, ',');
Expand All @@ -476,14 +485,13 @@ protected void startTable(Table table) {
table.setSchema(null);
}
Table targetTable = table.copy();
insertSql = DmlStatementFactory.createDmlStatement(compatible.toString()
.toLowerCase(), DmlType.INSERT, targetTable, useQuotedIdentifiers);
insertSql = DmlStatementFactory.createDmlStatement(databaseName,
DmlType.INSERT, targetTable, useQuotedIdentifiers);
}

if (!noCreateInfo) {
if (format == Format.SQL) {
IDdlBuilder target = DdlBuilderFactory.createDdlBuilder(compatible
.toString().toLowerCase());
IDdlBuilder target = DdlBuilderFactory.createDdlBuilder(databaseName);
target.setDelimitedIdentifierModeOn(useQuotedIdentifiers);
write(target.createTables(getDatabase(table), addDropTable));
} else if (format == Format.XML) {
Expand All @@ -492,8 +500,7 @@ protected void startTable(Table table) {
}
else if (addDropTable) {
if (format == Format.SQL) {
IDdlBuilder target = DdlBuilderFactory.createDdlBuilder(compatible
.toString().toLowerCase());
IDdlBuilder target = DdlBuilderFactory.createDdlBuilder(databaseName);
write(target.dropTables(getDatabase(table)));
}
}
Expand Down

0 comments on commit 56647fe

Please sign in to comment.