You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/09/14 10:51:40 UTC
[shardingsphere] branch master updated: fix alter view rename bug. (#20979)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f1cab653542 fix alter view rename bug. (#20979)
f1cab653542 is described below
commit f1cab653542d80b9a2b7a5cb4d39c3277862ecda
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Wed Sep 14 18:51:32 2022 +0800
fix alter view rename bug. (#20979)
---
.../infra/binder/statement/ddl/AlterViewStatementContext.java | 1 +
.../infra/binder/statement/ddl/AlterViewStatementContextTest.java | 2 ++
2 files changed, 3 insertions(+)
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContext.java
index a9224beb45c..2adf9a57195 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContext.java
@@ -49,6 +49,7 @@ public final class AlterViewStatementContext extends CommonSQLStatementContext<A
extractor.extractTablesFromSelect(optional);
tables.addAll(extractor.getRewriteTables());
});
+ AlterViewStatementHandler.getRenameView(sqlStatement).ifPresent(tables::add);
tablesContext = new TablesContext(tables, getDatabaseType());
}
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContextTest.java b/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContextTest.java
index 847efb2432f..5cd935cc874 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContextTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/test/java/org/apache/shardingsphere/infra/binder/statement/ddl/AlterViewStatementContextTest.java
@@ -60,6 +60,7 @@ public final class AlterViewStatementContextTest {
public void assertPostgreSQLNewInstance() {
PostgreSQLAlterViewStatement postgreSQLAlterViewStatement = mock(PostgreSQLAlterViewStatement.class);
when(postgreSQLAlterViewStatement.getView()).thenReturn(view);
+ when(postgreSQLAlterViewStatement.getRenameView()).thenReturn(Optional.of(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("view")))));
assertNewInstance(postgreSQLAlterViewStatement);
}
@@ -67,5 +68,6 @@ public final class AlterViewStatementContextTest {
AlterViewStatementContext actual = new AlterViewStatementContext(alterViewStatement);
assertThat(actual, instanceOf(CommonSQLStatementContext.class));
assertThat(actual.getSqlStatement(), is(alterViewStatement));
+ assertThat(actual.getAllTables().size(), is(2));
}
}