Skip to content

Commit

Permalink
Merge branch '3.10' of https://github.com/JumpMind/symmetric-ds.git i…
Browse files Browse the repository at this point in the history
…nto 3.10
  • Loading branch information
elong committed Dec 20, 2018
2 parents 2f2f4f6 + 4bdb368 commit b3b0533
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
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);
}
}
}
Expand Up @@ -40,6 +40,7 @@
import org.jumpmind.db.model.ColumnTypes;
import org.jumpmind.db.model.Database;
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.PlatformColumn;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.platform.DatabaseNamesConstants;
Expand All @@ -53,6 +54,8 @@ public class OracleDdlBuilder extends AbstractDdlBuilder {
protected static final String PREFIX_TRIGGER = "TRG";

protected static final String PREFIX_SEQUENCE = "SEQ";

protected static final String ROWID_TYPE = "ROWID";

public OracleDdlBuilder() {
super(DatabaseNamesConstants.ORACLE);
Expand Down Expand Up @@ -530,5 +533,17 @@ protected void processChange(Database currentModel, Database desiredModel,
printEndOfStatement(ddl);
change.apply(currentModel, delimitedIdentifierModeOn);
}


@Override
protected String getSqlType(Column column) {
PlatformColumn platformColumn = column.findPlatformColumn(databaseName);
if (platformColumn != null && platformColumn.getType() != null
&& platformColumn.getType().equals(ROWID_TYPE)) {
return ROWID_TYPE;
} else {
return super.getSqlType(column);
}
}

}
Expand Up @@ -38,6 +38,7 @@
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.io.data.IDataWriter;
import org.jumpmind.symmetric.io.data.writer.Conflict.DetectConflict;
import org.jumpmind.symmetric.io.data.writer.Conflict.PingBack;
import org.jumpmind.util.Statistics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -230,10 +231,20 @@ public void write(CsvData data) {
rollback();
throw ex;
} catch (RuntimeException ex) {
DatabaseWriterSettings writerSettings = getWriterSettings();
Statistics batchStatistics = getStatistics().get(getBatch());
long statementCount = batchStatistics.get(DataWriterStatisticConstants.ROWCOUNT);
long lineNumber = batchStatistics.get(DataWriterStatisticConstants.LINENUMBER);
ResolvedData resolvedData = getWriterSettings().getResolvedData(statementCount);

if (conflictResolver != null && conflictResolver.isIgnoreRow(this, data)) {
statistics.get(batch).increment(DataWriterStatisticConstants.IGNOREROWCOUNT);
} else if (conflictResolver != null && resolvedData != null) {
Conflict conflict = new Conflict();
conflict.setPingBack(PingBack.REMAINING_ROWS);
conflictResolver.attemptToResolve(resolvedData, data, this, conflict);
} else {
if (filterError(data, ex)) {
if (filterError(data, ex)) {
if (!(ex instanceof SqlException)) {
/*
* SQL exceptions should have already been logged
Expand Down
Expand Up @@ -227,7 +227,7 @@ protected void ignore(AbstractDatabaseWriter writer, Conflict conflict) {
}
}

protected void attemptToResolve(ResolvedData resolvedData, CsvData data, AbstractDatabaseWriter writer, Conflict conflict) {
public void attemptToResolve(ResolvedData resolvedData, CsvData data, AbstractDatabaseWriter writer, Conflict conflict) {
if (resolvedData != null) {
if (!resolvedData.isIgnoreRow()) {
data.putCsvData(CsvData.ROW_DATA, resolvedData.getResolvedData());
Expand Down
Expand Up @@ -30,4 +30,5 @@ public interface IDatabaseWriterConflictResolver extends IExtensionPoint {

public boolean isIgnoreRow(AbstractDatabaseWriter writer, CsvData data);

public void attemptToResolve(ResolvedData resolvedData, CsvData data, AbstractDatabaseWriter writer, Conflict conflict);
}

0 comments on commit b3b0533

Please sign in to comment.