This patch allows create column to see available types in the dropdown

Dave Cramer
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
index 11d40dd..ef08d48 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/utils.py
@@ -111,6 +111,11 @@ class BaseTableView(PGChildNodeView):
                 if server_type == 'gpdb' else
                 '#{0}#'.format(ver)
             )
+            self.data_type_template_path='datatype/sql/'+ (
+                '#{0}#{1}#'.format(server_type, ver)
+                if server_type == 'gpdb' else
+                '#{0}#'.format(ver)
+            )
             self.partition_template_path = 'partition/sql/#{0}#'.format(ver)
 
             # Template for Column ,check constraint and exclusion
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/gpdb_5.0_plus/get_types.sql
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/gpdb_5.0_plus/get_types.sql
new file mode 100644
index 0000000..7634321
--- /dev/null
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/gpdb_5.0_plus/get_types.sql
@@ -0,0 +1,25 @@
+SELECT
+    *
+FROM
+    (SELECT
+        format_type(t.oid,NULL) AS typname,
+        CASE WHEN typelem > 0 THEN typelem ELSE t.oid END as elemoid,
+        typlen, typtype, t.oid, nspname,
+        (SELECT COUNT(1) FROM pg_type t2 WHERE t2.typname = t.typname) > 1 AS 
isdup,
+        FALSE  AS is_collatable
+    FROM
+        pg_type t
+    JOIN
+        pg_namespace nsp ON typnamespace=nsp.oid
+    WHERE
+        (NOT (typname = 'unknown' AND nspname = 'pg_catalog'))
+    AND
+        {{ condition }}
+{% if add_serials %}
+{# Here we will add serials types manually #}
+    UNION SELECT 'smallserial', 0, 2, 'b', 0, 'pg_catalog', false, false
+    UNION SELECT 'bigserial', 0, 8, 'b', 0, 'pg_catalog', false, false
+    UNION SELECT 'serial', 0, 4, 'b', 0, 'pg_catalog', false, false
+{% endif %}
+    ) AS dummy
+ORDER BY nspname <> 'pg_catalog', nspname <> 'public', nspname, 1
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
index 085ab43..e086290 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
@@ -233,8 +233,14 @@ class TypeView(PGChildNodeView, DataTypeReader):
             # Declare allows acl on type
             self.acl = ['U']
 
-            # we will set template path for sql scripts
-            self.template_path = 'type/sql/#{0}#'.format(self.manager.version)
+            ver = self.manager.version
+            server_type = self.manager.server_type
+            # Set the template path for the SQL scripts
+            self.template_path = 'type/sql/' + (
+                '#{0}#{1}#'.format(server_type, ver)
+                if server_type == 'gpdb' else
+                '#{0}#'.format(ver)
+            )
 
             return f(*args, **kwargs)
         return wrap
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py
index 852724d..69e94b1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py
@@ -95,7 +95,7 @@ class DataTypeReader:
         try:
 
             SQL = render_template(
-                
'/datatype/sql/#{0}#/get_types.sql'.format(conn.manager.version),
+                "/".join([self.data_type_template_path,'get_types.sql']),
                 condition=condition,
                 add_serials=add_serials)
             status, rset = conn.execute_2darray(SQL)

Reply via email to