Skip to content

Commit

Permalink
Check implemented to prevent ignoring key fields in update mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jlolling committed Aug 25, 2022
1 parent 80a462c commit 28c0ed3
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.jlo.talendcomp</groupId>
<artifactId>jlo-talendcomp-tabletransfer</artifactId>
<version>12.0</version>
<version>12.1</version>
<name>Table Transfer Components</name>
<organization>
<name>Jan Lolling</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,9 @@ protected final SQLTable getTargetSQLTable() throws Exception {
// found target column without source
// remove target column
SQLField field = targetTable.getField(targetColumnName);
if (runOnlyUpdates && field.isPrimaryKey()) {
throw new Exception("Update mode can only be used when all primary key fields are part of the source query. PK-Field: " + field.getName() + " is missing in the source!");
}
// remove this field from table because
// the code generators takes the SQLTable for build sql code
targetTable.removeSQLField(field);
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions talend_component/tDB2TableTransfer/tDB2TableTransfer_java.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.0" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220819" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.1" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220822" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -160,13 +160,13 @@
<PARAMETER NAME="REUSE_DATA_MODEL" FIELD="CHECK" NUM_ROW="70">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="RELEASE_LABEL_20220819" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.0 build at: 20220819</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20220822" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.1 build at: 20220822</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.0.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.0/6.0.0-SNAPSHOT" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.1.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.1/6.0.0-SNAPSHOT" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Binary file not shown.
8 changes: 4 additions & 4 deletions talend_component/tEXATableTransfer/tEXATableTransfer_java.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.0" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220819" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.1" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220822" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -154,13 +154,13 @@
<PARAMETER NAME="REUSE_DATA_MODEL" FIELD="CHECK" NUM_ROW="70">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="RELEASE_LABEL_20220819" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.0 build at: 20220819</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20220822" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.1 build at: 20220822</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.0.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.0/6.0.0-SNAPSHOT" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.1.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.1/6.0.0-SNAPSHOT" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@
<%=cid%>.info("truncate target table...");
<%=cid%>.executeSQLOnTarget("truncate table " + <%=cid%>.getTargetTable());
<% } %>
<% if (outputToTable && disableKeys && onlyUpdate == false) { %>
<%=cid%>.info("disable keys on target table...");
<%=cid%>.executeSQLOnTarget("alter table " + <%=cid%>.getTargetTable() + " disable keys");
<% if (outputToTable && disableKeys && onlyUpdate == false && "UPDATE".equals(onConflict) == false && "IGNORE".equals(onConflict) == false) { %>
<%=cid%>.info("Disable keys on target table...");
<%=cid%>.executeSQLOnTarget("SET UNIQUE_CHECKS = 0");
<% } %>

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
String cid = node.getUniqueName();
boolean useDataSource = "true".equals(ElementParameterParser.getValue(node, "__USE_DATA_SOURCE__"));
boolean closeConnections = "true".equals(ElementParameterParser.getValue(node, "__CLOSE_CONNECTIONS__"));
boolean disableKeys = "true".equals(ElementParameterParser.getValue(node, "__TARGET_DISABLE_KEYS__"));
boolean outputToTable = "false".equals(ElementParameterParser.getValue(node, "__BACKUP_DATA_ONLY__"));
boolean onlyUpdate = "true".equals(ElementParameterParser.getValue(node, "__ONLY_UPDATE_NO_INSERT__"));
String onConflict = ElementParameterParser.getValue(node, "__ON_CONFLICT__");

<% if (outputToTable && disableKeys && onlyUpdate == false && "UPDATE".equals(onConflict) == false && "IGNORE".equals(onConflict) == false) { %>
<%=cid%>.info("Enable keys on target table...");
<%=cid%>.executeSQLOnTarget("SET UNIQUE_CHECKS = 1");
<% } %>

if (useDataSource || closeConnections) { %>
// disconnect in case of we use data sources means we put back the connection into the pool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.0" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220819" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.1" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220822" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -165,13 +165,13 @@
<PARAMETER NAME="REUSE_DATA_MODEL" FIELD="CHECK" NUM_ROW="70">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="RELEASE_LABEL_20220819" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.0 build at: 20220819</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20220822" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.1 build at: 20220822</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.0.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.0/6.0.0-SNAPSHOT" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.1.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.1/6.0.0-SNAPSHOT" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
globalMap.put("<%=cid%>_NB_LINE", <%=cid%>.getCurrentCountReads());
globalMap.put("<%=cid%>_NB_INSERTS", <%=cid%>.getCurrentCountInserts());
<% if (outputToTable) { %>
<%=cid%>.info("<%=cid%> [" + <%=cid%>.getTargetTable() + "] read:" + <%=cid%>.getCurrentCountReads() + " written:" + <%=cid%>.getCurrentCountInserts() + " rate inserts:" + insertsPerSecond_<%=cid%> + " rows/s");
<%=cid%>.info("<%=cid%> [" + <%=cid%>.getTargetTable() + "] read:" + <%=cid%>.getCurrentCountReads() + " written:" + <%=cid%>.getCurrentCountInserts() + " rate:" + insertsPerSecond_<%=cid%> + " rows/s");
<% } else { %>
<%=cid%>.info("<%=cid%> [" + <%=cid%>.getBackupFilePath() + "] read:" + <%=cid%>.getCurrentCountReads() + " written:" + <%=cid%>.getCurrentCountInserts() + " rate writes:" + insertsPerSecond_<%=cid%> + " rows/s");
<%=cid%>.info("<%=cid%> [" + <%=cid%>.getBackupFilePath() + "] read:" + <%=cid%>.getCurrentCountReads() + " written:" + <%=cid%>.getCurrentCountInserts() + " rate:" + insertsPerSecond_<%=cid%> + " rows/s");
<% } %>
} else {
<% if (outputToTable) { %>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.0" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220819" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.1" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220822" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -154,13 +154,13 @@
<PARAMETER NAME="REUSE_DATA_MODEL" FIELD="CHECK" NUM_ROW="70">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="RELEASE_LABEL_20220819" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.0 build at: 20220819</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20220822" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.1 build at: 20220822</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.0.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.0/6.0.0-SNAPSHOT" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.1.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.1/6.0.0-SNAPSHOT" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<COMPONENT>
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.0" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220819" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<HEADER PLATEFORM="ALL" SERIAL="" VERSION="12.1" STATUS="ALPHA" COMPATIBILITY="ALL" AUTHOR="Jan Lolling" RELEASE_DATE="20220822" STARTABLE="true" HAS_CONDITIONAL_OUTPUTS="false">
<SIGNATURE/>
</HEADER>
<FAMILIES>
Expand Down Expand Up @@ -162,13 +162,13 @@
<PARAMETER NAME="REUSE_DATA_MODEL" FIELD="CHECK" NUM_ROW="70">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="RELEASE_LABEL_20220819" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.0 build at: 20220819</DEFAULT>
<PARAMETER NAME="RELEASE_LABEL_20220822" FIELD="LABEL" COLOR="0;0;0" NUM_ROW="900">
<DEFAULT>Release: 12.1 build at: 20220822</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.0.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.0/6.0.0-SNAPSHOT" REQUIRED="true"/>
<IMPORT NAME="jlo-talendcomp-tabletransfer" MODULE="jlo-talendcomp-tabletransfer-12.1.jar" MVN="mvn:org.talend.libraries/jlo-talendcomp-tabletransfer-12.1/6.0.0-SNAPSHOT" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
<RETURNS>
Expand Down

0 comments on commit 28c0ed3

Please sign in to comment.