Skip to content

Commit

Permalink
Merge branch '3.7' of https://github.com/JumpMind/symmetric-ds into 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Jul 26, 2016
2 parents 027a73c + f479bcc commit 190d0d5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Expand Up @@ -133,7 +133,8 @@ private ParameterConstants() {

public final static String CREATE_TABLE_WITHOUT_DEFAULTS = "create.table.without.defaults";
public final static String CREATE_TABLE_WITHOUT_FOREIGN_KEYS = "create.table.without.foreign.keys";

public final static String CREATE_TABLE_WITHOUT_PK_IF_SOURCE_WITHOUT_PK = "create.table.without.pk.if.source.without.pk";

public final static String STREAM_TO_FILE_ENABLED = "stream.to.file.enabled";
public final static String STREAM_TO_FILE_THRESHOLD = "stream.to.file.threshold.bytes";
public final static String STREAM_TO_FILE_TIME_TO_LIVE_MS = "stream.to.file.ttl.ms";
Expand Down
Expand Up @@ -1603,14 +1603,15 @@ public CsvData next() {

this.targetTable = lookupAndOrderColumnsAccordingToTriggerHistory(
routerId, triggerHistory, true, true);
Table copyTargetTable = this.targetTable.copy();

Database db = new Database();
db.setName("dataextractor");
db.setCatalog(targetTable.getCatalog());
db.setSchema(targetTable.getSchema());
db.addTable(targetTable);
db.setCatalog(copyTargetTable.getCatalog());
db.setSchema(copyTargetTable.getSchema());
db.addTable(copyTargetTable);
if (excludeDefaults) {
Column[] columns = targetTable.getColumns();
Column[] columns = copyTargetTable.getColumns();
for (Column column : columns) {
column.setDefaultValue(null);
Map<String, PlatformColumn> platformColumns = column.getPlatformColumns();
Expand All @@ -1623,7 +1624,17 @@ public CsvData next() {
}
}
if (excludeForeignKeys) {
targetTable.removeAllForeignKeys();
copyTargetTable.removeAllForeignKeys();
}

if (parameterService.is(ParameterConstants.CREATE_TABLE_WITHOUT_PK_IF_SOURCE_WITHOUT_PK, false)
&& sourceTable.getPrimaryKeyColumnCount() == 0
&& copyTargetTable.getPrimaryKeyColumnCount() > 0) {

for (Column column : copyTargetTable.getColumns()) {
column.setPrimaryKey(false);
}

}
data.setRowData(CsvUtils.escapeCsvData(DatabaseXmlUtil.toXml(db)));
}
Expand Down
Expand Up @@ -1112,6 +1112,13 @@ create.table.without.defaults=false
# Type: boolean
create.table.without.foreign.keys=false

# If set to true, when a table's schema is sent to the target database it will not have all
# columns set as the primary key if the source does not have any primary keys.
#
# DatabaseOverridable: true
# Type: boolean
create.table.without.pk.if.source.without.pk=false

# Indicates that the current value of the row should be recorded in the incoming_error table
#
# DatabaseOverridable: true
Expand Down

0 comments on commit 190d0d5

Please sign in to comment.