Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aYw0X-0007cP-SM for pgadmin-hackers@arkaria.postgresql.org; Thu, 25 Feb 2016 13:31:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aYw0X-0000ky-Au for pgadmin-hackers@arkaria.postgresql.org; Thu, 25 Feb 2016 13:31:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aYw0W-0000kk-MG for pgadmin-hackers@postgresql.org; Thu, 25 Feb 2016 13:31:04 +0000 Received: from mail-ig0-x233.google.com ([2607:f8b0:4001:c05::233]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aYw0Q-0007tE-OU for pgadmin-hackers@postgresql.org; Thu, 25 Feb 2016 13:31:03 +0000 Received: by mail-ig0-x233.google.com with SMTP id y8so13344502igp.1 for ; Thu, 25 Feb 2016 05:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=L5RHr4f2jry5OB4tLqI2qAtHSUZxUq0coUUllJAUuzU=; b=DDkTKzSQd6wRYKnJ7TaNXuS3eMrwN9G5pVocGIJ7+ulckFuS0SpKyHSMkhnM2xtvU1 R4dvf26SS9CblVMPBv46jazT8th3Z0acivjzmC6JdjkV0GZVGHJ4L8LlhfFdMylBE6HX ctCtvHoPJjzLobEqJ7R/hbuQG1zrzz6Byw5iTdH+4Ri9UudIh3d3p6PuiQDUJG7RDCeF JGU7MTHQUbnNCYEJYJ9MVFMqEHlQvmfE/49tYEI//X90YgfE5ogSSi1qubFOLUlk/Fp3 B0FchDemsntaHv6JuOPh/mReHdDOWsQ4plYkTFDaiUuV3aacVIr8yTV/uY241wSaEkFq AiJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=L5RHr4f2jry5OB4tLqI2qAtHSUZxUq0coUUllJAUuzU=; b=mQJD/nsjDyO0+tAQNqDhrd/b+WlzYBN4sPXy7okTHAFk5WV8gqmMNPjkkeYMk/e1Qu CEB1K9SDI9cVm3D/gNMwkAaSMRxDIqruR5fWmTat7Vo2XKtAHzyfB07vlUtyD31duf0V i9lJd4tFRAWsbB25LU5p86ivUW25BYR4eryM7UusGdT9CqK5AxWj3Wp7AKz2Vco33b0I OCmuNxZj6GzKGEaBwZnQ78lByuFbzMeT11KGDyjLhkoVavWkafLyxYB4MwSaco7O6Vuo g4P5IOxJ1V2tOOinQkaJ7E5qU220APUewngnst1vYt/FbOKXsWgo5FZYqLy4DiVFn1PZ am5w== X-Gm-Message-State: AG10YOTqEbzigS4G2hjcElRE11KYzHn0UEXb8rIZL/gCf80Y1n3mV6rSoh9tx+yxVFnmdYRHuYTtLNWeJLdY9g== MIME-Version: 1.0 X-Received: by 10.50.61.100 with SMTP id o4mr2822477igr.69.1456407056713; Thu, 25 Feb 2016 05:30:56 -0800 (PST) Received: by 10.64.90.3 with HTTP; Thu, 25 Feb 2016 05:30:56 -0800 (PST) In-Reply-To: References: Date: Thu, 25 Feb 2016 13:30:56 +0000 Message-ID: Subject: Re: pgAdmin4 PATCH: Domain Module From: Dave Page To: Khushboo Vashi Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary=001a1135f13443cccd052c983164 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org --001a1135f13443cccd052c983164 Content-Type: text/plain; charset=UTF-8 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 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 --001a1135f13443cccd052c983164 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Per discussion with Khushboo, the patch at=C2=A0http://www.postgresql.org/message-id/attachment/41939/schemas_ma= cros_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 re= dundancy.

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

Please find attached Domain Mod= ule Patch.

Initial f= eedback:

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

- Length and Precision fields should only be enabled if appropriat= e for the data type.

The above still apply.
=C2=A0

=
- SQL generation for new Domains doesn't work:

This now works.
=C2=A0
=

- When adding constraints, I should be abl= e 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 s= till apply.
=C2=A0

- Erro= r seen when saving a domain: "macros/schemas/security.macros"

016-02-25 11:55:10,728: INFO werkzeug: 1= 27.0.0.1 - - [25/Feb/2016 11:55:10] "GET /browser/domain/msql/1/1/2458= 7/2200/?name=3Demail&owner=3Dpostgres&basensp=3Dpublic&descript= ion=3DThis+is+an+email+data+type&basetype=3Dtext&typlen=3D&prec= ision=3D&typdefault=3D&typnotnull=3Dtrue&collname=3D&constr= aints=3D%5B%5D&seclabels=3D%5B%5D&_=3D1456401124386 HTTP/1.1" = 500 -
Traceback (most recent call last):
=C2=A0 File &q= uot;/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/ap= p.py", line 1836, in __call__
=C2=A0 =C2=A0 return self.wsgi= _app(environ, start_response)
=C2=A0 File "/Users/dpage/.vir= tualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1820= , in wsgi_app
=C2=A0 =C2=A0 response =3D self.make_response(self.= handle_exception(e))
=C2=A0 File "/Users/dpage/.virtualenvs/= pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1403, in hand= le_exception
=C2=A0 =C2=A0 reraise(exc_type, exc_value, tb)
=
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py", line 1817, in wsgi_app
=C2=A0 =C2= =A0 response =3D self.full_dispatch_request()
=C2=A0 File "/= Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py&= quot;, line 1477, in full_dispatch_request
=C2=A0 =C2=A0 rv =3D s= elf.handle_user_exception(e)
=C2=A0 File "/Users/dpage/.virt= ualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py", line 1381,= in handle_user_exception
=C2=A0 =C2=A0 reraise(exc_type, exc_val= ue, tb)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/= python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_req= uest
=C2=A0 =C2=A0 rv =3D self.dispatch_request()
=C2= =A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packag= es/flask/app.py", line 1461, in dispatch_request
=C2=A0 =C2= =A0 return self.view_functions[rule.endpoint](**req.view_args)
= =C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-pac= kages/flask/views.py", line 84, in view
=C2=A0 =C2=A0 return= self.dispatch_request(*args, **kwargs)
=C2=A0 File "/Users/= dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line 248, in dispatc= h_request
=C2=A0 =C2=A0 return method(*args, **kwargs)
= =C2=A0 File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_grou= ps/servers/databases/schemas/domains/__init__.py", line 277, in wrap
=C2=A0 =C2=A0 return f(*args, **kwargs)
=C2=A0 File &quo= t;/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/datab= ases/schemas/domains/__init__.py", line 232, in wrap
=C2=A0 = =C2=A0 return f(self, **kwargs)
=C2=A0 File "/Users/dpage/gi= t/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/doma= ins/__init__.py", line 700, in msql
=C2=A0 =C2=A0 status=3D2= 00
=C2=A0 File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/= ajax.py", line 41, in make_json_response
=C2=A0 =C2=A0 respo= nse=3Djson.dumps(doc, cls=3DDataTypeJSONEncoder),
=C2=A0 File &qu= ot;/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejso= n/__init__.py", line 386, in dumps
=C2=A0 =C2=A0 **kw).encod= e(obj)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/p= ython2.7/site-packages/simplejson/encoder.py", line 269, in encode
=C2=A0 =C2=A0 chunks =3D self.iterencode(o, _one_shot=3DTrue)
<= div>=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site= -packages/simplejson/encoder.py", line 348, in iterencode
= =C2=A0 =C2=A0 return _iterencode(o, 0)
=C2=A0 File "/Users/d= page/git/pgadmin4/web/pgadmin/utils/ajax.py", line 26, in default
=C2=A0 =C2=A0 return json.JSONEncoder.default(self, obj)
= =C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-pac= kages/simplejson/encoder.py", line 246, in default
=C2=A0 = =C2=A0 raise TypeError(repr(o) + " is not JSON serializable")
TypeError: TemplateNotFound() is not JSON serializable=C2=A0

This issue is resolved.

Additional issues:

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

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

- Reverse engineere= d SQL doesn't include the normal header and commented-out drop statemen= t.

Thanks.

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

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL= Company
--001a1135f13443cccd052c983164--