Re: pgAdmin4 PATCH: Domain Module - Mailing list pgadmin-hackers

From Dave Page
Subject Re: pgAdmin4 PATCH: Domain Module
Date
Msg-id CA+OCxoxkows1UUgaddq3+R2VcTW9Vmc3QCKdrtd1sNP+fDsHTg@mail.gmail.com
Whole thread Raw
In response to Re: pgAdmin4 PATCH: Domain Module  (Dave Page <dpage@pgadmin.org>)
Responses Re: pgAdmin4 PATCH: Domain Module
List pgadmin-hackers
Per discussion with Khushboo, the patch at http://www.postgresql.org/message-id/attachment/41939/schemas_macros_10_Feb_2.patch is a pre-req for this. Updated comments below...

On Thu, Feb 25, 2016 at 12:13 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi

On Wed, Feb 24, 2016 at 9:24 AM, Khushboo Vashi <khushboo.vashi@enterprisedb.com> wrote:
Hi,

I have updated the Domain module as below:

- Used 'NodeByListControl' to get schemas, in domains.js file as suggested by Ashesh to avoid code redundancy.

- Applied 'Security Label Macro'  Patch (Implemented by Harshal) and removed same changes from the Domain Patch.
  To test Domain patch, 'Security Label Macro' patch must be applied first as that is not committed yet.

Please find attached Domain Module Patch.

Initial feedback:

- Owner and schema should be allowed to be left blank (and then default to the current user/schema)

- Length and Precision fields should only be enabled if appropriate for the data type.

The above still apply.
 

- SQL generation for new Domains doesn't work:

This now works.
 

- When adding constraints, I should be able to type directly into the grid. Expanding the row should be optional.

- The comment column on the constraints grid expands when the text reaches ~50% of the width. It should be a fixed size (and use 100% of the space available, less appropriate margins).

- Backend support checks should not special-case Slony schemas.

- 4 character indentation not used consistently in SQL templates.

These still apply.
 

- Error seen when saving a domain: "macros/schemas/security.macros"

016-02-25 11:55:10,728: INFO werkzeug: 127.0.0.1 - - [25/Feb/2016 11:55:10] "GET /browser/domain/msql/1/1/24587/2200/?name=email&owner=postgres&basensp=public&description=This+is+an+email+data+type&basetype=text&typlen=&precision=&typdefault=&typnotnull=true&collname=&constraints=%5B%5D&seclabels=%5B%5D&_=1456401124386 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1820, 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 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1461, 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 248, in dispatch_request
    return method(*args, **kwargs)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py", line 277, in wrap
    return f(*args, **kwargs)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py", line 232, in wrap
    return f(self, **kwargs)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py", line 700, in msql
    status=200
  File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/ajax.py", line 41, in make_json_response
    response=json.dumps(doc, cls=DataTypeJSONEncoder),
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/__init__.py", line 386, in dumps
    **kw).encode(obj)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py", line 269, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py", line 348, in iterencode
    return _iterencode(o, 0)
  File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/ajax.py", line 26, in default
    return json.JSONEncoder.default(self, obj)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/encoder.py", line 246, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: TemplateNotFound() is not JSON serializable 

This issue is resolved.

Additional issues:

- We can add a comment to constraints (and view them), however they are not saved.

- The domain is not created as a single SQL statement, but by creating a domain over the base type, then adding constraints. Can this be done in one query?

- Reverse engineered SQL doesn't include the normal header and commented-out drop statement.

Thanks.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: pgAdmin4 PATCH: Domain Module
Next
From: Dave Page
Date:
Subject: Re: PATCH: PGADMIN 4 - FTS templates node