提交 4a560bf8 authored 作者: Niklas Mehner's avatar Niklas Mehner

Fix bug when using column names in insert statement.

上级 54ecaaf6
......@@ -43,6 +43,16 @@ public class TableSynonym extends Table {
return getSynonymFor().getColumns();
}
@Override
public Column getColumn(String columnName) {
return getSynonymFor().getColumn(columnName);
}
@Override
public Column getColumn(int index) {
return getSynonymFor().getColumn(index);
}
@Override
public boolean lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc) {
return getSynonymFor().lock(session, exclusive, forceLockEvenInMvcc);
......
......@@ -16,7 +16,7 @@ import java.sql.SQLException;
import java.sql.Statement;
/**
* Test for the read-only database feature.
* Tests for table synonyms.
*/
public class TestSynonymForTable extends TestBase {
......@@ -33,6 +33,7 @@ public class TestSynonymForTable extends TestBase {
public void test() throws SQLException {
testSelectFromSynonym();
testInsertIntoSynonym();
testInsertWithColumnNameIntoSynonym();
testDeleteFromSynonym();
testTruncateSynonym();
testExistingTableName();
......@@ -244,6 +245,18 @@ public class TestSynonymForTable extends TestBase {
conn.close();
}
private void testInsertWithColumnNameIntoSynonym() throws SQLException {
Connection conn = getConnection("synonym");
createTableWithSynonym(conn);
PreparedStatement prep = conn.prepareStatement(
"INSERT INTO testsynonym (id) VALUES(?)");
prep.setInt(1, 55);
prep.execute();
assertBackingTableContains(conn, 55);
conn.close();
}
private void assertBackingTableContains(Connection conn, int testValue) throws SQLException {
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT id FROM backingtable");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论