Skip to content

Commit

Permalink
TEIIDDES-2688 added check for old VDB's containing CREATE VIRTUAL
Browse files Browse the repository at this point in the history
PROCEDURE in SQL statement. If so, then don't duplicate the statement
start on export.
  • Loading branch information
blafond committed Oct 14, 2015
1 parent da52c06 commit de1769e
Showing 1 changed file with 9 additions and 7 deletions.
Expand Up @@ -9,9 +9,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand Down Expand Up @@ -362,9 +360,13 @@ private String procedure(Procedure procedure) {
// > ???
if( isVirtual && !isFunction ) {
TransformationMappingRoot tRoot = (TransformationMappingRoot)TransformationHelper.getTransformationMappingRoot(procedure);
String sqlString = TransformationHelper.getSelectSqlString(tRoot);
String sqlString = TransformationHelper.getSelectSqlString(tRoot).replace(CREATE_VIRTUAL_PROCEDURE, StringConstants.EMPTY_STRING);

if( sqlString != null ) {
sb.append(NEW_LINE + TAB).append(Reserved.AS).append(NEW_LINE + SPACE).append(sqlString);
if( sqlString.indexOf('\n') == 0 ) {
sqlString = sqlString.replace(StringConstants.NEW_LINE, StringConstants.EMPTY_STRING);
}
sb.append(NEW_LINE + TAB).append(Reserved.AS).append(NEW_LINE).append(sqlString);
if( ! sqlString.endsWith(SEMI_COLON)) sb.append(SEMI_COLON);
sb.append(NEW_LINE);
}
Expand Down Expand Up @@ -696,16 +698,16 @@ private String escapeSinglePart(String token) {
* Utility to check a unique constraint and determine if it is redundant. Basically if the uc columns match a PK with the same columns
*/
private Collection<UniqueConstraint> getUniqueUniqueContraints(BaseTable table) {
EList ucs = table.getUniqueConstraints();
EList<?> ucs = table.getUniqueConstraints();
Collection<UniqueConstraint> uniqueConstraints = new ArrayList<UniqueConstraint>();

PrimaryKey pk = table.getPrimaryKey();

for( Object obj: ucs) {
UniqueConstraint uc = (UniqueConstraint)obj;
if( pk != null ) {
EList pkColumns = pk.getColumns();
EList ucColumns = uc.getColumns();
EList<?> pkColumns = pk.getColumns();
EList<?> ucColumns = uc.getColumns();

if( pkColumns.size() == ucColumns.size() ) {
boolean matchesAll = true;
Expand Down

0 comments on commit de1769e

Please sign in to comment.