Skip to content

Commit

Permalink
TEIIDDES-1735 added check for no TABLE_REFERENCE_REFERENCES properties
Browse files Browse the repository at this point in the history
  • Loading branch information
blafond committed May 17, 2013
1 parent 81d2c2f commit 5271541
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,14 @@ private void createTeiidConstraint(final AstNode constraintNode,
final Object tempRefColumns = constraintNode.getProperty(TeiidDdlLexicon.Constraint.TABLE_REFERENCE_REFERENCES);

final List<AstNode> foreignTableColumnNodes = (tempRefColumns==null) ? Collections.<AstNode>emptyList() : (List<AstNode>)tempRefColumns;
if (primaryKeyColumns.size() == foreignTableColumnNodes.size()) {
if(!foreignTableColumnNodes.isEmpty()) {
for(AstNode fTableColumn : foreignTableColumnNodes) {
find(Column.class, fTableColumn, tableRef, roots);
}
int numPKColumns = primaryKeyColumns.size();
int numFKColumns = foreignTableColumnNodes.size();

if( foreignTableColumnNodes.isEmpty() ) {
foreignKey.setUniqueKey(tableRefPrimaryKey);
} else if( numPKColumns == numFKColumns ) {
for(AstNode fTableColumn : foreignTableColumnNodes) {
find(Column.class, fTableColumn, tableRef, roots);
}
foreignKey.setUniqueKey(tableRefPrimaryKey);
// } else {
Expand All @@ -557,6 +560,8 @@ private void createTeiidConstraint(final AstNode constraintNode,
// break;
// }
// }
} else {
foreignKey.setUniqueKey(tableRefPrimaryKey);
}
} catch (final EntityNotFoundException error) {
messages.add(error.getMessage());
Expand Down

0 comments on commit 5271541

Please sign in to comment.