Author: shawkins
Date: 2012-06-18 20:14:18 -0400 (Mon, 18 Jun 2012)
New Revision: 4185
Modified:
trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
Log:
TEIID-2076 fix for not performing implicit update
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-06-18
16:09:18 UTC (rev 4184)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-06-19
00:14:18 UTC (rev 4185)
@@ -211,7 +211,7 @@
}
}
- GroupSymbol symbol = new GroupSymbol(t.getName(), t.getFullName());
+ GroupSymbol symbol = new GroupSymbol(t.getName());
ResolverUtil.resolveGroup(symbol, metadata);
// this seems to parse, resolve and validate.
Modified: trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-06-18
16:09:18 UTC (rev 4184)
+++ trunk/runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java 2012-06-19
00:14:18 UTC (rev 4185)
@@ -34,9 +34,12 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.adminapi.Model.Type;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.jdbc.TeiidDriver;
+import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
+import org.teiid.metadata.Column;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
@@ -47,6 +50,7 @@
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.TypeFacility;
+import org.teiid.translator.UpdateExecution;
@SuppressWarnings("nls")
public class TestEmbeddedServer {
@@ -82,7 +86,9 @@
throws TranslatorException {
assertEquals(conn, Integer.valueOf(1));
Table t = metadataFactory.addTable("my-table");
- metadataFactory.addColumn("my-column", TypeFacility.RUNTIME_NAMES.STRING,
t);
+ t.setSupportsUpdate(true);
+ Column c = metadataFactory.addColumn("my-column",
TypeFacility.RUNTIME_NAMES.STRING, t);
+ c.setUpdatable(true);
}
@Override
@@ -114,6 +120,37 @@
};
return rse;
}
+
+ @Override
+ public UpdateExecution createUpdateExecution(Command command,
+ ExecutionContext executionContext,
+ RuntimeMetadata metadata, Object connection)
+ throws TranslatorException {
+ UpdateExecution ue = new UpdateExecution() {
+
+ @Override
+ public void execute() throws TranslatorException {
+
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException,
+ TranslatorException {
+ return new int[] {2};
+ }
+ };
+ return ue;
+ }
});
final AtomicInteger counter = new AtomicInteger();
ConnectionFactoryProvider<AtomicInteger> cfp = new
ConnectionFactoryProvider<AtomicInteger>() {
@@ -130,14 +167,23 @@
mmd.setName("my-schema");
mmd.addSourceMapping("x", "y", "z");
- es.deployVDB("test", Arrays.asList(mmd));
+ ModelMetaData mmd1 = new ModelMetaData();
+ mmd1.setName("virt");
+ mmd1.setModelType(Type.VIRTUAL);
+ mmd1.setSchemaSourceType("ddl");
+ mmd1.setSchemaText("create view \"my-view\" (\"my-column\"
string OPTIONS (UPDATABLE 'true')) OPTIONS (UPDATABLE 'true') as select *
from \"my-table\"");
+
+ es.deployVDB("test", Arrays.asList(mmd, mmd1));
TeiidDriver td = es.getDriver();
Connection c = td.connect("jdbc:teiid:test", null);
Statement s = c.createStatement();
- ResultSet rs = s.executeQuery("select * from \"my-table\"");
+ ResultSet rs = s.executeQuery("select * from \"my-view\"");
assertFalse(rs.next());
assertEquals("my-column", rs.getMetaData().getColumnLabel(1));
+
+ s.execute("update \"my-view\" set \"my-column\" =
'a'");
+ assertEquals(2, s.getUpdateCount());
}
}
Show replies by date