Hi,

Please find attached patch to fix issue related to table OF TYPE property.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
index 7f6aa0c..7560be4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js
@@ -725,19 +725,33 @@ define('pgadmin.node.table', [
                   arg = undefined,
                   column_collection = self.model.get('columns');
 
-                if (!_.isUndefined(tbl_name) &&
+                if (!_.isUndefined(tbl_name) && !_.isNull(tbl_name) &&
                     tbl_name !== '' && column_collection.length !== 0) {
-                  var msg = gettext('Changing of type table will clear columns collection');
-                  alertify.confirm(msg, function (e) {
-                    if (e) {
+                  var title = gettext('Remove column definitions?'),
+                      msg = gettext('Changing \'Of type\' will remove column definitions.');
+
+                  alertify.confirm(title, msg, function (e) {
                       // User clicks Ok, lets clear columns collection
-                      column_collection.reset();
-                    } else {
-                      return this;
+                      column_collection.remove(
+                        column_collection.filter(function(model) {
+                          return true;
+                          }
+                        )
+                      );
+                    },
+                    function() {
+                      setTimeout(function() {
+                        self.model.set('typname', null);
+                      }, 10)
                     }
-                  });
+                  );
                 } else if (!_.isUndefined(tbl_name) && tbl_name === '') {
-                  column_collection.reset();
+                  column_collection.remove(
+                    column_collection.filter(function(model) {
+                      return true;
+                      }
+                    )
+                  );
                 }
 
                 // Run Ajax now to fetch columns
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/create.sql
index 5ec8ffc..ffb6b84 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/default/create.sql
@@ -18,7 +18,7 @@
 {% endif %}
 CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data.schema, data.name)}}{{empty_bracket}}
 {% if data.typname %}
-    OF {{ conn|qtTypeIdent(data.typname) }}
+    OF {{ data.typname }}
 {% endif %}
 {% if data.like_relation or data.coll_inherits or data.columns|length > 0 or data.primary_key|length > 0 or data.unique_constraint|length > 0 or data.foreign_key|length > 0 or data.check_constraint|length > 0 or data.exclude_constraint|length > 0 %}
 (

Reply via email to