Skip to content

Commit

Permalink
Merge branch '3.8' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.8
  • Loading branch information
mmichalek committed Jul 31, 2017
2 parents 0f4f46c + f056eed commit e6c67fc
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 37 deletions.
Expand Up @@ -184,7 +184,7 @@ public void saveNodeGroupLink(NodeGroupLink link) {
if (sqlTemplate.update(getSql("updateNodeGroupLinkSql"), link.getDataEventAction().name(),
link.isSyncConfigEnabled() ? 1 : 0, link.isReversible() ? 1 : 0,
link.getLastUpdateTime(),
link.getLastUpdateBy(), link.getSourceNodeGroupId(), link.getTargetNodeGroupId()) == 0) {
link.getLastUpdateBy(), link.getSourceNodeGroupId(), link.getTargetNodeGroupId()) <= 0) {
link.setCreateTime(new Date());
sqlTemplate.update(getSql("insertNodeGroupLinkSql"), link.getDataEventAction().name(),
link.getSourceNodeGroupId(), link.getTargetNodeGroupId(),
Expand All @@ -206,7 +206,7 @@ public boolean doesNodeGroupExist(String nodeGroupId) {
public void saveNodeGroup(NodeGroup group) {
group.setLastUpdateTime(new Date());
if (sqlTemplate.update(getSql("updateNodeGroupSql"), group.getDescription(),
group.getLastUpdateTime(), group.getLastUpdateBy(), group.getNodeGroupId()) == 0) {
group.getLastUpdateTime(), group.getLastUpdateBy(), group.getNodeGroupId()) <= 0) {
group.setCreateTime(new Date());
sqlTemplate.update(getSql("insertNodeGroupSql"), group.getDescription(),
group.getNodeGroupId(), group.getLastUpdateTime(), group.getLastUpdateBy(),
Expand Down Expand Up @@ -284,7 +284,7 @@ public boolean isChannelInUse(String channelId) {

public void saveChannel(Channel channel, boolean reloadChannels) {
channel.setLastUpdateTime(new Date());
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateChannelSql"),
new Object[] { channel.getProcessingOrder(), channel.getMaxBatchSize(),
channel.getMaxBatchToSend(), channel.getMaxDataToRoute(),
Expand Down Expand Up @@ -327,7 +327,7 @@ public void saveNodeChannel(NodeChannel nodeChannel, boolean reloadChannels) {
}

public void saveNodeChannelControl(NodeChannel nodeChannel, boolean reloadChannels) {
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateNodeChannelControlSql"),
new Object[] { nodeChannel.isSuspendEnabled() ? 1 : 0,
nodeChannel.isIgnoreEnabled() ? 1 : 0, nodeChannel.getLastExtractTime(),
Expand Down
Expand Up @@ -87,12 +87,12 @@ public void save(String name, String value) {
@Override
public void save(ISqlTransaction transaction, String name, String value) {
if (transaction != null) {
if (update(transaction, name, value) == 0) {
if (update(transaction, name, value) <= 0) {
insert(transaction, name, value);
}
} else {
int count = sqlTemplate.update(getSql("updateSql"), value, name);
if (count == 0) {
if (count <= 0) {
sqlTemplate.update(getSql("insertSql"), name, value);
}
}
Expand Down
Expand Up @@ -773,7 +773,7 @@ public void save(ConflictNodeGroupLink setting) {
setting.getLastUpdateBy(), setting.getConflictId() }, new int[] {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) == 0) {
Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) <= 0) {
sqlTemplate.update(
getSql("insertConflictSettingsSql"),
new Object[] { setting.getNodeGroupLink().getSourceNodeGroupId(),
Expand Down
Expand Up @@ -287,7 +287,7 @@ public void saveExtension(Extension extension) {
Object[] args = { extension.getExtensionType(), extension.getInterfaceName(), extension.getNodeGroupId(),
extension.isEnabled() ? 1 : 0, extension.getExtensionOrder(), extension.getExtensionText(), extension.getLastUpdateBy(),
extension.getExtensionId() };
if (sqlTemplate.update(getSql("updateExtensionSql"), args) == 0) {
if (sqlTemplate.update(getSql("updateExtensionSql"), args) <= 0) {
sqlTemplate.update(getSql("insertExtensionSql"), args);
if (extension.isEnabled()) {
registerExtension(extension);
Expand Down
Expand Up @@ -277,7 +277,7 @@ public FileTriggerRouter getFileTriggerRouter(String triggerId, String routerId)

public void saveFileTrigger(FileTrigger fileTrigger) {
fileTrigger.setLastUpdateTime(new Date());
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateFileTriggerSql"),
new Object[] { fileTrigger.getBaseDir(), fileTrigger.isRecurse() ? 1 : 0,
fileTrigger.getIncludesFiles(), fileTrigger.getExcludesFiles(),
Expand Down Expand Up @@ -319,7 +319,7 @@ public void saveFileTrigger(FileTrigger fileTrigger) {

public void saveFileTriggerRouter(FileTriggerRouter fileTriggerRouter) {
fileTriggerRouter.setLastUpdateTime(new Date());
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateFileTriggerRouterSql"),
new Object[] { fileTriggerRouter.isEnabled() ? 1 : 0,
fileTriggerRouter.isInitialLoadEnabled() ? 1 : 0,
Expand Down
Expand Up @@ -251,7 +251,7 @@ public void saveGrouplet(Grouplet grouplet) {
grouplet.getCreateTime(), grouplet.getLastUpdateBy(),
grouplet.getLastUpdateTime(), grouplet.getGroupletId() }, new int[] {
Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR,
Types.TIMESTAMP, Types.VARCHAR }) == 0) {
Types.TIMESTAMP, Types.VARCHAR }) <= 0) {
grouplet.setCreateTime(new Date());
sqlTemplate.update(
getSql("insertGroupletSql"),
Expand Down Expand Up @@ -295,7 +295,7 @@ public void saveGroupletLink(Grouplet grouplet, GroupletLink link) {
new Object[] { link.getCreateTime(), link.getLastUpdateBy(),
link.getLastUpdateTime(), grouplet.getGroupletId(), link.getExternalId() },
new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR,
Types.VARCHAR }) == 0) {
Types.VARCHAR }) <= 0) {
link.setCreateTime(new Date());
sqlTemplate.update(getSql("insertGroupletLinkSql"), new Object[] {
link.getCreateTime(), link.getLastUpdateBy(), link.getLastUpdateTime(),
Expand All @@ -322,7 +322,7 @@ public void saveTriggerRouterGrouplet(Grouplet grouplet,
triggerRouterGrouplet.getAppliesWhen().name(),
triggerRouterGrouplet.getTriggerId(), triggerRouterGrouplet.getRouterId() },
new int[] { Types.TIMESTAMP, Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) == 0) {
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }) <= 0) {
triggerRouterGrouplet.setCreateTime(new Date());
sqlTemplate.update(
getSql("insertTriggerRouterGroupletSql"),
Expand Down
Expand Up @@ -213,7 +213,7 @@ public void saveLoadFilter(LoadFilterNodeGroupLink loadFilter) {
loadFilter.isFilterOnUpdate() ? 1 : 0, loadFilter.isFilterOnDelete() ? 1 : 0,
loadFilter.isFailOnError() ? 1 : 0, loadFilter.getLastUpdateBy(),
loadFilter.getLastUpdateTime(), loadFilter.getLoadFilterId() };
if (sqlTemplate.update(getSql("updateLoadFilterSql"), args) == 0) {
if (sqlTemplate.update(getSql("updateLoadFilterSql"), args) <= 0) {
sqlTemplate.update(getSql("insertLoadFilterSql"), args);
}
clearCache();
Expand Down
Expand Up @@ -333,7 +333,7 @@ public boolean delete(NodeCommunication nodeCommunication) {

protected void save(NodeCommunication nodeCommunication, boolean force) {
if (clusterService.isClusteringEnabled() || force) {
if (0 == sqlTemplate.update(getSql("updateNodeCommunicationSql"),
if (0 >= sqlTemplate.update(getSql("updateNodeCommunicationSql"),
nodeCommunication.getLockTime(), nodeCommunication.getLockingServerId(),
nodeCommunication.getLastLockMillis(), nodeCommunication.getSuccessCount(),
nodeCommunication.getFailCount(), nodeCommunication.getTotalSuccessCount(),
Expand Down
Expand Up @@ -185,7 +185,7 @@ public void ignoreNodeChannelForExternalId(boolean enabled, String channelId,
String nodeGroupId, String externalId) {
Node node = findNodeByExternalId(nodeGroupId, externalId);
if (sqlTemplate.update(getSql("nodeChannelControlIgnoreSql"), new Object[] {
enabled ? 1 : 0, node.getNodeId(), channelId }) == 0) {
enabled ? 1 : 0, node.getNodeId(), channelId }) <= 0) {
sqlTemplate.update(getSql("insertNodeChannelControlSql"),
new Object[] { node.getNodeId(), channelId, enabled ? 1 : 0, 0 });
}
Expand Down Expand Up @@ -218,7 +218,7 @@ public void updateNodeHost(NodeHost nodeHost) {
nodeHost.getLastRestartTime(), nodeHost.getNodeId(),
nodeHost.getHostName() };

if (sqlTemplate.update(getSql("updateNodeHostSql"), params) == 0) {
if (sqlTemplate.update(getSql("updateNodeHostSql"), params) <= 0) {
sqlTemplate.update(getSql("insertNodeHostSql"), params);
}

Expand Down
Expand Up @@ -1000,7 +1000,7 @@ public void saveTriggerRouter(TriggerRouter triggerRouter, boolean updateTrigger
saveRouter(triggerRouter.getRouter());
}
triggerRouter.setLastUpdateTime(new Date());
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateTriggerRouterSql"),
new Object[] { triggerRouter.getInitialLoadOrder(),
triggerRouter.getInitialLoadSelect(),
Expand Down Expand Up @@ -1041,7 +1041,7 @@ protected void resetTriggerRouterCacheByNodeGroupId() {
public void saveRouter(Router router) {
router.setLastUpdateTime(new Date());
router.nullOutBlankFields();
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateRouterSql"),
new Object[] { router.getTargetCatalogName(), router.getTargetSchemaName(),
router.getTargetTableName(),
Expand Down Expand Up @@ -1094,7 +1094,7 @@ public void deleteAllRouters() {
public void saveTrigger(Trigger trigger) {
trigger.setLastUpdateTime(new Date());
trigger.nullOutBlankFields();
if (0 == sqlTemplate.update(
if (0 >= sqlTemplate.update(
getSql("updateTriggerSql"),
new Object[] { trigger.getSourceCatalogName(), trigger.getSourceSchemaName(),
trigger.getSourceTableName(), trigger.getChannelId(), trigger.getReloadChannelId(),
Expand Down
Expand Up @@ -69,7 +69,7 @@ public NuoDbDdlBuilder() {
databaseInfo.addNativeTypeMapping(Types.CHAR, "CHAR");
databaseInfo.addNativeTypeMapping(Types.VARCHAR, "VARCHAR");
databaseInfo.addNativeTypeMapping(Types.TIMESTAMP, "TIMESTAMP");
databaseInfo.addNativeTypeMapping(Types.TINYINT, "SMALLINT");
databaseInfo.addNativeTypeMapping(Types.TINYINT, "SMALLINT",Types.SMALLINT);
databaseInfo.addNativeTypeMapping(Types.SMALLINT, "SMALLINT");
databaseInfo.addNativeTypeMapping(Types.INTEGER, "INTEGER");
databaseInfo.addNativeTypeMapping(Types.BIGINT, "BIGINT");
Expand Down Expand Up @@ -106,15 +106,26 @@ public NuoDbDdlBuilder() {
@Override
protected String getFullyQualifiedTableNameShorten(Table table) {
String result="";
// if (StringUtils.isNotBlank(table.getSchema())) {
// result+=getDelimitedIdentifier(table.getSchema()).concat(databaseInfo.getSchemaSeparator());
// }else{
// result+=getDelimitedIdentifier(platform.getDefaultSchema()).concat(databaseInfo.getSchemaSeparator());
// }
result+=getDelimitedIdentifier(getTableName(table.getName()));
return result;
}


@Override
public boolean areColumnSizesTheSame(Column sourceColumn, Column targetColumn){
if(sourceColumn.getMappedType().equals("DECIMAL") && targetColumn.getMappedType().equals("DECIMAL")){
int targetSize = targetColumn.getSizeAsInt();
int sourceSize = sourceColumn.getSizeAsInt();
if (targetSize > 8 && sourceSize == 8 &&
targetColumn.getScale() == sourceColumn.getScale()) {
return true;
}else{
return false;
}
}else{
return super.areColumnSizesTheSame(sourceColumn, targetColumn);
}
}

@Override
protected void dropTable(Table table, StringBuilder ddl, boolean temporary, boolean recreate) {
ddl.append("DROP TABLE IF EXISTS ");
Expand Down Expand Up @@ -193,11 +204,6 @@ protected void writeExternalForeignKeyCreateStmt(Database database, Table table,
ddl.append(" FOREIGN KEY (");
writeLocalReferences(key, ddl);
ddl.append(") REFERENCES ");
// if (StringUtils.isNotBlank(table.getSchema())) {
// ddl.append(table.getSchema()).append(".");
// }else{
// ddl.append(platform.getDefaultSchema()).append(".");
// }
printIdentifier(getTableName(key.getForeignTableName()), ddl);
ddl.append(" (");
writeForeignReferences(key, ddl);
Expand Down
Expand Up @@ -75,7 +75,7 @@ protected static Map<String,String> mapNames(){
values.put("TYPE_NAME", "TYPE_NAME");
values.put("DATA_TYPE", "DATA_TYPE");
values.put("NUM_PREC_RADIX", "NUM_PREC_RADIX");
values.put("DECIMAL_DIGITS", "DECIMAL_DIGITS");
values.put("DECIMAL_DIGITS", "SCALE");
values.put("COLUMN_SIZE", "LENGTH");
values.put("IS_NULLABLE", "IS_NULLABLE");
values.put("IS_AUTOINCREMENT", "IS_AUTOINCREMENT");
Expand Down Expand Up @@ -244,10 +244,7 @@ protected Integer mapUnknownJdbcTypeForColumn(Map<String, Object> values) {
}

Integer type = (Integer) values.get("DATA_TYPE");
if (type != null && type.intValue() == Types.SMALLINT) {
// XML booleanint becomes tinyint on Column but becomes smallint in database
return Types.TINYINT;
} else if (type != null && type.intValue() == Types.CLOB) {
if (type != null && type.intValue() == Types.CLOB) {
// XML longvarchar becoms longvarchar on Column but becomes clob in database
return Types.LONGVARCHAR;
} else {
Expand Down

0 comments on commit e6c67fc

Please sign in to comment.