Unverified 提交 45501baf authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1662 from mhewedy/master

Fix Alter Table Drop Column In View when table name is wrapped by Double Quotes
...@@ -296,7 +296,7 @@ public class AlterTableAlterColumn extends CommandWithColumns { ...@@ -296,7 +296,7 @@ public class AlterTableAlterColumn extends CommandWithColumns {
// (because the column to drop is referenced or so) // (because the column to drop is referenced or so)
checkViews(table, newTable); checkViews(table, newTable);
} catch (DbException e) { } catch (DbException e) {
execute("DROP TABLE " + newTable.getName(), true); execute("DROP TABLE " + newTable.getSQL(), true);
throw e; throw e;
} }
String tableName = table.getName(); String tableName = table.getName();
......
...@@ -46,6 +46,7 @@ public class TestViewAlterTable extends TestDb { ...@@ -46,6 +46,7 @@ public class TestViewAlterTable extends TestDb {
testJoinAndAlias(); testJoinAndAlias();
testSubSelect(); testSubSelect();
testForeignKey(); testForeignKey();
testAlterTableDropColumnInViewWithDoubleQuotes();
conn.close(); conn.close();
deleteDb(getTestName()); deleteDb(getTestName());
...@@ -197,4 +198,18 @@ public class TestViewAlterTable extends TestDb { ...@@ -197,4 +198,18 @@ public class TestViewAlterTable extends TestDb {
} }
} }
// original error: table "XX_COPY_xx_xx" not found
private void testAlterTableDropColumnInViewWithDoubleQuotes() throws SQLException{
// simple
stat.execute("create table \"test\"(id identity, name varchar) " +
"as select x, 'Hello'");
stat.execute("create view test_view as select * from \"test\"");
assertThrows(ErrorCode.COLUMN_IS_REFERENCED_1, stat).
execute("alter table \"test\" drop name");
ResultSet rs = stat.executeQuery("select * from test_view");
assertTrue(rs.next());
stat.execute("drop view test_view");
stat.execute("drop table \"test\"");
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论