public inbox for [email protected]
help / color / mirror / Atom feedFrom: Harshal Dhumal <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: Patch for RM1500 other issues [pgAdmin4]
Date: Wed, 3 Aug 2016 17:13:44 +0530
Message-ID: <CAFiP3vyNABWTtNK+rtOByWOyeotHQFT7Kv_1jnrKORGTFBobaQ@mail.gmail.com> (raw)
In-Reply-To: <CA+OCxowcG2dX4XS-aTkbOm8GF=XqiV343aYz5c6qTUq4UYF4aQ@mail.gmail.com>
References: <CAFiP3vyQX28ZAbMB4cSnU3-o_s1O1VP6hdQjz6uq=oRFH-9scg@mail.gmail.com>
<CA+OCxowcG2dX4XS-aTkbOm8GF=XqiV343aYz5c6qTUq4UYF4aQ@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi Dave,
This because on python 2.X simplejson throws KeyError instead of TypeError
if any error occurs while loading json data from given object. Now I have
handled that exception as well in attached patch.
I'm sending this as separate patch instead part of RM1500.
--
*Harshal Dhumal*
*Software Engineer*
EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Wed, Aug 3, 2016 at 4:12 PM, Dave Page <[email protected]> wrote:
> Hi
>
> On Wed, Aug 3, 2016 at 7:36 AM, Harshal Dhumal
> <[email protected]> wrote:
> > Hi,
> >
> > PFA patch for RM1500.
> >
> > Changes/Issues fixed:
> >
> > 1] datamodel.js: For collection type added check before adding model into
> > "changed" list instead of adding it blindly.
> >
> > 2] Type casting from str to int of column properties like attlen,
> > attpricision.
> >
> > 3] Added missing data formating when adding new column to existing table
> > (from table edit mode).
> >
> > 4] Added more validation for Foreign key constraint.
> >
> > 5] Column.js: Column grid (in table edit mode) show proper disabled color
> > for disabled cell when grid renders.
> >
> > 6] All constraints and index js added idattribute to distinguish which
> > s/constraint or s/index is updated on server side.
> >
> > 7] Column update.sql: Fixed sql when altering column data type. The issue
> > was when we alter data type from which has length and precision to data
> type
> > which don't have these properties and vice versa.
> > For e.g. alter data type numeric(10,12) to real (and vice versa)
> >
> > 8] Renaming constraint (RM1500).
>
> I get the following error when renaming a primary key. I have
> restarted my app sever and done a hard reload/clear cache on my
> browser. The generated SQL is:
>
> ALTER TABLE public.foo
> RENAME CONSTRAINT foo_pkey TO foo_pkey1;
>
>
> 2016-08-03 11:39:43,764: INFO werkzeug: 127.0.0.1 - - [03/Aug/2016
> 11:39:43] "PUT /browser/table/obj/1/1/12403/2200/158521 HTTP/1.1" 500
> -
> Traceback (most recent call last):
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1625, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
> File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line
> 235, in dispatch_request
> return method(*args, **kwargs)
> File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
> line 331, in wrap
> return f(*args, **kwargs)
> File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
> line 1446, in update
> data[k] = json.loads(v, encoding='utf-8')
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/__init__.py",
> line 533, in loads
> return cls(encoding=encoding, **kw).decode(s)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/decoder.py",
> line 370, in decode
> obj, end = self.raw_decode(s)
> File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/decoder.py",
> line 395, in raw_decode
> ord0 = ord(s[idx])
> KeyError: 0
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[text/x-patch] simplejson_handle_load_exception_on_python_2.X.X.patch (5.4K, 3-simplejson_handle_load_exception_on_python_2.X.X.patch)
download | inline diff:
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 b67783c..ef5cbe4 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
@@ -515,7 +515,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
required_args = {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
index 8f0a815..3405ded 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
@@ -403,7 +403,7 @@ class CheckConstraintView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
for arg in required_args:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index 7a6396d..26115f7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -448,7 +448,7 @@ class ExclusionConstraintView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
for arg in required_args:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
index b6d996b..9a2ee06 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
@@ -471,7 +471,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
for arg in required_args:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
index 37fb8f2..ecdbd8b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -451,7 +451,7 @@ class IndexConstraintView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
for arg in required_args:
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 fa67947..d79c946 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
@@ -528,7 +528,7 @@ class IndexesView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
required_args = {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
index a639df0..b3e4eec 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
@@ -543,7 +543,7 @@ class TriggerView(PGChildNodeView):
for k, v in data.items():
try:
data[k] = json.loads(v, encoding='utf-8')
- except (ValueError, TypeError):
+ except (ValueError, TypeError, KeyError):
data[k] = v
required_args = {
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Patch for RM1500 other issues [pgAdmin4]
In-Reply-To: <CAFiP3vyNABWTtNK+rtOByWOyeotHQFT7Kv_1jnrKORGTFBobaQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox