Skip to content

Commit

Permalink
Don't use row for insert/update in order to get good sql strings when…
Browse files Browse the repository at this point in the history
… doing a --dry-run
  • Loading branch information
uli-heller committed Mar 11, 2014
1 parent 2d8af4a commit c8792cb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions jdbc-copy/scripts/jdbcCopy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,22 @@ class tableDescription {
if (fDoInsert) {
++insertCnt;
String insertFieldList = keySet.join(',');
def colonizedKeySet = keySet.collect{ ":${it}" };
String insertColonizedFieldList = colonizedKeySet.join(',')
sqlCommand = "insert into ${tableName} ( ${insertFieldList} ) values ( ${insertColonizedFieldList} )";
//def colonizedKeySet = keySet.collect{ ":${it}" };
//String insertColonizedFieldList = colonizedKeySet.join(',')
//sqlCommand = "insert into ${tableName} ( ${insertFieldList} ) values ( ${insertColonizedFieldList} )";
def values = keySet.collect{ prepareIdForSql(row.get(it)) };
String insertValues = values.join(',');
sqlCommand = "insert into ${tableName} ( ${insertFieldList} ) values ( ${insertValues} )";
} else if (fDoUpdate) {
assert thisId != null;
String prepared = prepareIdForSql(thisId);
++updateCnt;
def updateSet = keySet.collect{ "${it} = :${it}" };
//def updateSet = keySet.collect{ "${it} = :${it}" };
def updateSet = keySet.collect{ "${it} = ${prepareIdForSql(row.get(it))}" };
sqlCommand = "update ${tableName} set ${updateSet.join(",")} where ${id}=${prepared}";
}
sqlExecute(to, sqlCommand, row);
//sqlExecute(to, sqlCommand, row);
sqlExecute(to, sqlCommand);
}
to.commit(); // commit in order to free the blob objects
++cnt;
Expand Down

0 comments on commit c8792cb

Please sign in to comment.