Hi,
PFA minor patch to handle "char" type while creating columns in Column node.
*Issue:* simplejson parse '*"char"*' as valid json, hence when we perform
simplejson.loads(request.args) operation '"char"' gets converted to 'char'
I had to handle it manually as of now, I did not find any other workaround
to handle this issue, I went over several SO question most of them
suggested manual handling.
This behavior is only in Column node, table & type nodes are not affectted
by .loads() method as we send data as column collection.
RM#2152
*Snippet of issue:*
import simplejson as json
print(json.loads('"char"'))
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index ac9a103..225e694 100644
---
a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++
b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -490,6 +490,15 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
after length/precision so we will set flag for
sql template
"""
+
+ # We need to add this exceptional case for manually adding " in type
+ # in json.loads('"char"') is valid json hence it
+ # converts '"char"' -> 'char' as string but if we
+ # send the same in collection json.loads() handles it properly in
+ # Table & Type nodes, This handling handling is Column node specific
+ if type == 'char':
+ type = '"char"'
+
if '[]' in type:
type = type.replace('[]', '')
self.hasSqrBracket = True
@@ -710,7 +719,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
for k, v in request.args.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except ValueError:
+ except (ValueError, TypeError, KeyError):
data[k] = v
# Adding parent into data dict, will be using it while creating sql
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers