Skip to content

Commit

Permalink
TEIID-5357 correcting the auto-naming
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jun 3, 2018
1 parent 401ace7 commit 9f75110
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
Expand Up @@ -6081,7 +6081,7 @@ void createColumn(MetadataFactory factory, Table table) :
if (index){
factory.addIndex("INDEX"+table.getIndexes().size(), true, columnName, table);
} else if (unique){
factory.addIndex("UNIQUE"+table.getIndexes().size(), false, columnName, table);
factory.addIndex("UNIQUE"+table.getUniqueKeys().size(), false, columnName, table);
} else if (pk) {
if (table.getPrimaryKey() != null) {
throw new MetadataException(QueryPlugin.Util.getString("SQLParser.pk_exists", table.getName()));
Expand Down
Expand Up @@ -19,13 +19,17 @@

import static org.junit.Assert.*;

import java.util.List;
import java.util.Properties;

import org.junit.Before;
import org.junit.Test;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.metadata.BaseColumn.NullType;
import org.teiid.metadata.Column;
import org.teiid.metadata.Column.SearchType;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.ParseException;
Expand Down Expand Up @@ -611,6 +615,22 @@ public void testSkipDocumentModel() throws Exception {
assertTrue(printError(report), report.hasItems());
}

@Test
public void testMultipleUnique() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1(\n" +
"e1 integer primary key,\n" +
"e2 varchar(10) unique,\n" +
"e3 date not null unique)";

buildModel("phy1", true, this.vdb, this.store, ddl);

buildTransformationMetadata();

ValidatorReport report = new MetadataValidator().validate(this.vdb, this.store);

assertFalse(printError(report), report.hasItems());
}

private ValidatorReport helpTest(String ddl, boolean expectErrors) throws Exception {
buildModel("pm1", true, this.vdb, this.store, ddl);

Expand Down

0 comments on commit 9f75110

Please sign in to comment.