From 281b6c91b5f61e64e876ebb93202de93d6e020d2 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Thu, 30 Nov 2017 12:49:09 +0530 Subject: [PATCH] Using the correct type name (along with the internal name) while generating the query for update/insert table data (Data grid). Modified by Ashesh for array support. Fixes #2830 --- web/pgadmin/tools/sqleditor/__init__.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index a4b83d4cb..8dcb44483 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -708,6 +708,7 @@ def poll(trans_id): col_type = dict() col_type['type_code'] = col['type_code'] col_type['type_name'] = None + col_type['internal_size'] = col['internal_size'] columns[col['name']] = col_type if rset: @@ -727,7 +728,29 @@ def poll(trans_id): for col_info in columns.values(): for col_type in types: if col_type['oid'] == col_info['type_code']: - col_info['type_name'] = col_type['typname'] + typname = col_type['typname'] + + # If column is of type character, character[], + # character varying and character varying[] + # then add internal size to it's name for the + # correct sql query. + if col_info['internal_size'] >= 0: + if ( + typname == 'character' or + typname == 'character varying' + ): + typname = typname + '(' + \ + str(col_info['internal_size']) + \ + ')' + elif ( + typname == 'character[]' or + typname == 'character varying[]' + ): + typname = typname[:-2] + '(' + \ + str(col_info['internal_size']) + \ + ')[]' + + col_info['type_name'] = typname session_obj['columns_info'] = columns # status of async_fetchmany_2darray is True and result is none