You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by GitBox <gi...@apache.org> on 2019/08/08 14:58:51 UTC

[GitHub] [metamodel] kaspersorensen commented on a change in pull request #225: METAMODEL-1217 - Fixes dropping JDBC Tables with view as TableType

kaspersorensen commented on a change in pull request #225: METAMODEL-1217 - Fixes dropping JDBC Tables with view as TableType
URL: https://github.com/apache/metamodel/pull/225#discussion_r312084000
 
 

 ##########
 File path: jdbc/src/main/java/org/apache/metamodel/jdbc/JdbcDropTableBuilder.java
 ##########
 @@ -63,10 +64,15 @@ public void execute() {
     }
 
     protected String createSqlStatement() {
-        FromItem fromItem = new FromItem(getTable());
-        String tableLabel = _queryRewriter.rewriteFromItem(fromItem);
+        final Table table = getTable();
+        final FromItem fromItem = new FromItem(table);
+        final String tableLabel = _queryRewriter.rewriteFromItem(fromItem);
 
-        return "DROP TABLE " + tableLabel;
+        if (table.getType() != null && table.getType() == TableType.VIEW) {
+            return "DROP VIEW " + tableLabel;
 
 Review comment:
   I wonder if we could simply go like this:
   
   ```
   TableType type = table.getType() == null ? TableType.TABLE : table.getType();
   return "DROP " + type + " " + tableLabel;
   ```
   
   Oh, and I would maybe rename `tableLabel` to `qualifiedTableName` or something.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services