Hi,

PFA minor patch to fix the issue where sql from CREATE Script/SQL Panel
doesn't escape column names in Table reversed engineered sql (if table has
index) & Index reversed engineered sql.
RM#2619

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

[image: https://community.postgresrocks.net/]
<https://community.postgresrocks.net/>
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
index 670dccd..ee48ef3 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
@@ -480,7 +480,7 @@ class IndexesView(PGChildNodeView):
             status=200
         )
 
-    def _column_details(self, idx, data):
+    def _column_details(self, idx, data, mode='properties'):
         """
         This functional will fetch list of column details for index
 
@@ -504,8 +504,10 @@ class IndexesView(PGChildNodeView):
         cols = []
         for row in rset['rows']:
             # We need all data as collection for ColumnsModel
+            # we will not strip down colname when using in SQL to display
             cols_data = {
-                'colname': row['attdef'].strip('"'),
+                'colname': row['attdef'] if mode == 'create' else
+                row['attdef'].strip('"'),
                 'collspcname': row['collnspname'],
                 'op_class': row['opcname'],
             }
@@ -901,7 +903,7 @@ class IndexesView(PGChildNodeView):
         data['table'] = self.table
 
         # Add column details for current index
-        data = self._column_details(idx, data)
+        data = self._column_details(idx, data, 'create')
 
         SQL, name = self.get_sql(did, scid, tid, None, data)
         if not isinstance(SQL, (str, unicode)):
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 d212faf..d9b69ec 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
@@ -923,8 +923,9 @@ class BaseTableView(PGChildNodeView):
             cols = []
             for col_row in rset['rows']:
                 # We need all data as collection for ColumnsModel
+                # Only for displaying SQL, we can omit strip on colname
                 cols_data = {
-                    'colname': col_row['attdef'].strip('"'),
+                    'colname': col_row['attdef'],
                     'collspcname': col_row['collnspname'],
                     'op_class': col_row['opcname'],
                 }

Reply via email to