You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/26 01:12:08 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #21748: Add validate for duplicated single table.

strongduanmu commented on code in PR #21748:
URL: https://github.com/apache/shardingsphere/pull/21748#discussion_r1005119086


##########
kernel/single-table/core/src/main/java/org/apache/shardingsphere/singletable/route/engine/SingleTableStandardRouteEngine.java:
##########
@@ -80,13 +81,20 @@ private Map<String, RouteUnit> getDataSourceRouteUnits(final RouteContext newRou
     private void route0(final RouteContext routeContext, final SingleTableRule rule) {
         if (sqlStatement instanceof CreateTableStatement) {
             String dataSourceName = rule.assignNewDataSourceName();
-            String tableName = singleTableNames.iterator().next().getTableName();
-            routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper(dataSourceName, dataSourceName), Collections.singleton(new RouteMapper(tableName, tableName))));
+            QualifiedTable table = singleTableNames.iterator().next();
+            if (isDuplicatedTable(table, rule)) {
+                throw new DuplicatedSingleTableException(table.getTableName());

Review Comment:
   Can we use TableExistsException here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org