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/12 08:12:03 UTC

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

GerardDellemann 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_r312814036
 
 

 ##########
 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:
   TableType has the following values: TABLE, VIEW, SYSTEM_TABLE, GLOBAL_TEMPORARY, LOCAL_TEMPORARY, ALIAS, SYNONYM, OTHER.
   In SQL you either drop a table or a view (you don't drop a system_table, that's a table). I would say that the VIEW value is only relevant for droping views. All the other values beloing to droping tables.
   TableType has no toString implementation. You could implement a custom toString just for this JdbcDropTableBuilder#createSqlStatement() method, but I don't think that would be a very representable implementation of that method.

----------------------------------------------------------------
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