Skip to content

Commit

Permalink
Merge branch '3.9' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.9
  • Loading branch information
mmichalek committed Dec 20, 2018
2 parents 60ce61a + 3301ff0 commit c36f33e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 44 deletions.
Expand Up @@ -212,49 +212,6 @@ public void testInsertBlobRandom() {
}
}

@Test
public void testDuplicateRow(){
if (shouldTestRun(platform)) {
platform.getSqlTemplate().update("truncate table " + getTestTable());
List<CsvData> data = new ArrayList<CsvData>();

String id=getNextId();
String[] values1 = { id, "stri'ng2", "string not null2", "char2", "char not null2",
"2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", encode("string") };
data.add(new CsvData(DataEventType.INSERT, values1));

String[] values2 = { id, "stri'ng2", "string not null2", "char2", "char not null2",
"2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", encode("string") };
data.add(new CsvData(DataEventType.INSERT, values2));

Table table = platform.getTableFromCache(getTestTable(), false);
AbstractDatabaseWriter bulkWriter = create();

DataContext context = new DataContext();

try {
/* first try should have failed */
writeData(bulkWriter, context, new TableCsvData(table, data));
fail("The bulk writer should have failed");
} catch (Exception ex) {
}

/* Recreate the writer because in the real world that is what would happen */
bulkWriter = create();
context = new DataContext();

IncomingBatch expectedBatch = new IncomingBatch();
expectedBatch.setErrorFlag(true);
context.put("currentBatch", expectedBatch);

/* second try should be success because the bulk writer should fail back to using the default writer */
long statementCount = writeData(bulkWriter, context, new TableCsvData(table, data));

Assert.assertEquals(2, statementCount);
Assert.assertEquals(1, countRows(getTestTable()));
}
}

protected abstract AbstractDatabaseWriter create();


Expand Down
Expand Up @@ -1112,7 +1112,9 @@ protected int insertDataEvents(ProcessInfo processInfo, ChannelRouterContext con
context.setLastLoadId(loadId);
}
batch.setLoadId(loadId);
context.setNeedsCommitted(true);
if (context.getChannel().isReloadFlag()) {
context.setNeedsCommitted(true);
}
} else {
context.setLastLoadId(-1);
}
Expand Down
Expand Up @@ -30,4 +30,23 @@ protected int getTypeCode(Column column, boolean isDateOverrideToTimestamp) {
return super.getTypeCode(column, isDateOverrideToTimestamp);
}
}

@Override
protected void appendColumnParameter(StringBuilder sql, Column column) {
if (column.getJdbcTypeName() != null && column.getJdbcTypeName().equals("datetime2") && column.getMappedTypeCode() == Types.VARCHAR) {
sql.append("cast(? AS datetime2(6))").append(",");
} else {
super.appendColumnParameter(sql, column);
}
}

@Override
protected void appendColumnEquals(StringBuilder sql, Column column) {
if (column.getJdbcTypeName() != null && column.getJdbcTypeName().equals("datetime2") && column.getMappedTypeCode() == Types.VARCHAR) {
sql.append(quote).append(column.getName()).append(quote)
.append(" = cast(? AS datetime2(6))");
} else {
super.appendColumnEquals(sql, column);
}
}
}

0 comments on commit c36f33e

Please sign in to comment.