Hi Dave, PFA the patch for cast module incorporating changes regarding showing system objects. Apart from support for showing system object I have resolved few bugs in that, unnecessary code and added nodes.sql file.
Please do review it and if it looks good, please commit. Regards, Sanket Mehta Sr Software engineer Enterprisedb On Fri, Mar 4, 2016 at 4:33 PM, Dave Page <dp...@pgadmin.org> wrote: > Thanks, patch applied. > > On Tue, Mar 1, 2016 at 7:20 AM, Sanket Mehta > <sanket.me...@enterprisedb.com> wrote: > > Hi, > > > > There was an error in cast module while fetching its dependency and > > dependent. > > Below is the patch which resolves this issue. > > Please review and commit it. > > > > > > > > Regards, > > Sanket Mehta > > Sr Software engineer > > Enterprisedb > > > > On Wed, Feb 24, 2016 at 10:17 PM, Dave Page <dp...@pgadmin.org> wrote: > >> > >> Thanks - committed. > >> > >> On Tue, Feb 23, 2016 at 1:34 PM, Sanket Mehta > >> <sanket.me...@enterprisedb.com> wrote: > >>> > >>> Hi, > >>> > >>> PFA the revised patch as per your comments. > >>> Please review it and let me know the feedback. > >>> > >>> Regards, > >>> Sanket Mehta > >>> Sr Software engineer > >>> Enterprisedb > >>> > >>> On Tue, Feb 23, 2016 at 4:10 PM, Dave Page <dp...@pgadmin.org> wrote: > >>>> > >>>> Hi > >>>> > >>>> I've attached an update to this patch, in which I've done some > >>>> word-smithing on various comments, and adjusted the SQL templates to > improve > >>>> the formatting. > >>>> > >>>> However, it looks like it's bit-rotted, as the dependents/dependencies > >>>> display is throwing Python errors. Please fix and then I think it's > just > >>>> about ready to commit. > >>>> > >>>> Thanks. > >>>> > >>>> > >>>> On Fri, Feb 19, 2016 at 11:03 AM, Sanket Mehta > >>>> <sanket.me...@enterprisedb.com> wrote: > >>>>> > >>>>> Hi Dave, > >>>>> > >>>>> PFA the revise patch. > >>>>> > >>>>> It includes changes according to your review comments as well as > >>>>> dependency/dependent part also. > >>>>> > >>>>> Let me know in case anything is missing. > >>>>> > >>>>> Regards, > >>>>> Sanket Mehta > >>>>> Sr Software engineer > >>>>> Enterprisedb > >>>>> > >>>>> On Mon, Feb 15, 2016 at 10:25 PM, Dave Page <dp...@pgadmin.org> > wrote: > >>>>>> > >>>>>> And this time with the attachment... > >>>>>> > >>>>>> On Mon, Feb 15, 2016 at 4:53 PM, Dave Page <dp...@pgadmin.org> > wrote: > >>>>>>> > >>>>>>> That's much better. Just a couple of comments now, partly based on > an > >>>>>>> email I wrote earlier: > >>>>>>> > >>>>>>> - There is still inconsistency in comment style. Please see the > >>>>>>> attachment for an example. Note that there is *always* a space > between the > >>>>>>> comment marker and text. > >>>>>>> > >>>>>>> - If I try to edit a cast, I can change the description - but no > SQL > >>>>>>> is shown on the SQL tab, despite the comment being correctly > applied when I > >>>>>>> hit save. The properties pane of the main window is also not > updated. > >>>>>>> > >>>>>>> Otherwise, it looks fine. > >>>>>>> > >>>>>>> Thanks. > >>>>>>> > >>>>>>> On Mon, Feb 15, 2016 at 1:28 PM, Sanket Mehta > >>>>>>> <sanket.me...@enterprisedb.com> wrote: > >>>>>>>> > >>>>>>>> Hi, > >>>>>>>> > >>>>>>>> PFA the revised patch with all the required comments. > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> Regards, > >>>>>>>> Sanket Mehta > >>>>>>>> Sr Software engineer > >>>>>>>> Enterprisedb > >>>>>>>> > >>>>>>>> On Mon, Feb 15, 2016 at 4:18 PM, Dave Page <dp...@pgadmin.org> > >>>>>>>> wrote: > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> On Mon, Feb 15, 2016 at 8:10 AM, Sanket Mehta > >>>>>>>>> <sanket.me...@enterprisedb.com> wrote: > >>>>>>>>>> > >>>>>>>>>> Hi Dave, > >>>>>>>>>> > >>>>>>>>>> Regarding your suggestion of putting some comments in > javascript, > >>>>>>>>>> I think I have already put some comments regarding model data > and their > >>>>>>>>>> controls if any extended. > >>>>>>>>>> > >>>>>>>>>> Can you please let me know where exactly you think more comments > >>>>>>>>>> are required? > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> Hi > >>>>>>>>> > >>>>>>>>> The issue for me is that jQuery code isn't the easiest to read at > >>>>>>>>> the best of times, with nested/anonymous functions and inline > JSON etc. As I > >>>>>>>>> look through the code for the various nodes in isolation, it's > extremely > >>>>>>>>> difficult to get a sense of what exactly each part of the code > is doing. In > >>>>>>>>> this example, what I see by reading the code is: > >>>>>>>>> > >>>>>>>>> - Define the required libraries (require.js stuff) > >>>>>>>>> - Extend the collection class > >>>>>>>>> - Extend the node class > >>>>>>>>> - Define an init function inline > >>>>>>>>> - Add the menu options > >>>>>>>>> > >>>>>>>>> That part is fairly easy to figure out (easier because there are > >>>>>>>>> blank lines between the logical sections). From there though, it > becomes > >>>>>>>>> much harder; > >>>>>>>>> > >>>>>>>>> - There are no blank lines to separate logical code sections at > all > >>>>>>>>> between line 48 and 235 (there is one blank line, but it doesn't > separate > >>>>>>>>> code sections). > >>>>>>>>> - There are 4 comments that I can see. The first two are > identical, > >>>>>>>>> and appear to have identical code blocks following them for > reasons that are > >>>>>>>>> not even remotely obvious. > >>>>>>>>> - As a newcomer to this code, I'm wondering if it's purpose is to > >>>>>>>>> define the backform model. If so, why is it not broken up into > sections with > >>>>>>>>> a comment to tell me what field each block handles, and any > other useful > >>>>>>>>> information I may need to know? If it's not, then what is it for? > >>>>>>>>> > >>>>>>>>> So... I'm not going to tell you exactly where to put comments, > >>>>>>>>> because the point is that without spending a couple of hours > understanding > >>>>>>>>> this, I simply don't know. The point of the comments (and > separation of > >>>>>>>>> logical sections of code with blank lines) is to make it easy > for another > >>>>>>>>> developer (especially one as rusty as me) to read and > understand, then fix > >>>>>>>>> and improve. Be generous with comments, but don't use them > unnecessarily > >>>>>>>>> (e.g. "a = 1 // Set a to one"). > >>>>>>>>> > >>>>>>>>> Of course, this is not just directed at you Sanket - it's > something > >>>>>>>>> all of us working on pgAdmin need to keep in mind. > >>>>>>>>> > >>>>>>>>> Thanks. > >>>>>>>>> > >>>>>>>>> -- > >>>>>>>>> Dave Page > >>>>>>>>> Blog: http://pgsnake.blogspot.com > >>>>>>>>> Twitter: @pgsnake > >>>>>>>>> > >>>>>>>>> EnterpriseDB UK: http://www.enterprisedb.com > >>>>>>>>> The Enterprise PostgreSQL Company > >>>>>>>> > >>>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> -- > >>>>>>> Dave Page > >>>>>>> Blog: http://pgsnake.blogspot.com > >>>>>>> Twitter: @pgsnake > >>>>>>> > >>>>>>> EnterpriseDB UK: http://www.enterprisedb.com > >>>>>>> The Enterprise PostgreSQL Company > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> -- > >>>>>> Dave Page > >>>>>> Blog: http://pgsnake.blogspot.com > >>>>>> Twitter: @pgsnake > >>>>>> > >>>>>> EnterpriseDB UK: http://www.enterprisedb.com > >>>>>> The Enterprise PostgreSQL Company > >>>>> > >>>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> Dave Page > >>>> Blog: http://pgsnake.blogspot.com > >>>> Twitter: @pgsnake > >>>> > >>>> EnterpriseDB UK: http://www.enterprisedb.com > >>>> The Enterprise PostgreSQL Company > >>> > >>> > >> > >> > >> > >> -- > >> Dave Page > >> Blog: http://pgsnake.blogspot.com > >> Twitter: @pgsnake > >> > >> EnterpriseDB UK: http://www.enterprisedb.com > >> The Enterprise PostgreSQL Company > > > > > > > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py index cdec278..88477bb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py @@ -225,7 +225,8 @@ class CastView(PGChildNodeView): """ sql = render_template( "/".join([self.template_path, 'properties.sql']), - datlastsysoid=self.manager.db_info[did]['datlastsysoid'] + datlastsysoid=self.manager.db_info[did]['datlastsysoid'], + showsysobj=self.blueprint.show_system_objects ) status, res = self.conn.execute_dict(sql) @@ -252,15 +253,15 @@ class CastView(PGChildNodeView): """ res = [] sql = render_template( - "/".join([self.template_path, 'properties.sql']), - datlastsysoid=self.manager.db_info[did]['datlastsysoid'] + "/".join([self.template_path, 'nodes.sql']), + datlastsysoid=self.manager.db_info[did]['datlastsysoid'], + showsysobj=self.blueprint.show_system_objects ) status, rset = self.conn.execute_2darray(sql) if not status: return internal_server_error(errormsg=rset) for row in rset['rows']: - row['castcontext'] = True if row['castcontext'] == 'IMPLICIT' else False res.append( self.blueprint.generate_browser_node( row['oid'], @@ -275,6 +276,31 @@ class CastView(PGChildNodeView): ) @check_precondition + def node(self, gid, sid, did, cid): + res = [] + sql = render_template( + "/".join([self.template_path, 'nodes.sql']), + cid=cid + ) + status, rset = self.conn.execute_2darray(sql) + if not status: + return internal_server_error(errormsg=rset) + + for row in rset['rows']: + res.append( + self.blueprint.generate_browser_node( + row['oid'], + did, + row['name'], + icon="icon-fts_template" + )) + + return make_json_response( + data=res, + status=200 + ) + + @check_precondition def properties(self, gid, sid, did, cid): """ This function will show the properties of the selected cast node @@ -287,7 +313,8 @@ class CastView(PGChildNodeView): sql = render_template( "/".join([self.template_path, 'properties.sql']), cid=cid, - datlastsysoid=self.manager.db_info[did]['datlastsysoid'] + datlastsysoid=self.manager.db_info[did]['datlastsysoid'], + showsysobj=self.blueprint.show_system_objects ) status, res = self.conn.execute_dict(sql) @@ -338,7 +365,8 @@ class CastView(PGChildNodeView): sql = render_template("/".join([self.template_path, 'properties.sql']), srctyp=data['srctyp'], trgtyp=data['trgtyp'], - datlastsysoid=self.manager.db_info[did]['datlastsysoid'] + datlastsysoid=self.manager.db_info[did]['datlastsysoid'], + showsysobj=self.blueprint.show_system_objects ) status, cid = self.conn.execute_scalar(sql) if not status: @@ -485,7 +513,8 @@ class CastView(PGChildNodeView): if cid is not None: sql = render_template("/".join([self.template_path, 'properties.sql']), cid=cid, - datlastsysoid=self.manager.db_info[did]['datlastsysoid']) + datlastsysoid=self.manager.db_info[did]['datlastsysoid'], + showsysobj=self.blueprint.show_system_objects) status, res = self.conn.execute_dict(sql) if not status: @@ -614,7 +643,7 @@ class CastView(PGChildNodeView): did: Database ID cid: Cast ID """ - dependents_result = self.get_dependents(self.conn, cid, 'cast') + dependents_result = self.get_dependents(self.conn, cid) return ajax_response( response=dependents_result, status=200 @@ -632,7 +661,7 @@ class CastView(PGChildNodeView): did: Database ID cid: Cast ID """ - dependencies_result = self.get_dependencies(self.conn, cid, 'cast') + dependencies_result = self.get_dependencies(self.conn, cid) return ajax_response( response=dependencies_result, status=200 diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/create.sql index cef76ca..edd2444 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/create.sql @@ -1,10 +1,5 @@ {# CREATE CAST Statement #} -{% if is_sql %} --- Cast: {{conn|qtTypeIdent(data.srctyp)}}->{{ conn|qtTypeIdent(data.trgtyp) }}; --- DROP CAST ({{ conn|qtTypeIdent(data.srctyp) }} AS {{ conn|qtTypeIdent(data.trgtyp) }}); - -{% endif %} {% if data and data.srctyp and data.trgtyp %} CREATE CAST ({{ conn|qtTypeIdent(data.srctyp) }} AS {{ conn|qtTypeIdent(data.trgtyp) }}) {% if data.proname and data.proname != 'binary compatible'%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/nodes.sql b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/nodes.sql new file mode 100644 index 0000000..87f331f --- /dev/null +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/nodes.sql @@ -0,0 +1,23 @@ + SELECT + ca.oid, + concat(format_type(st.oid,NULL),'->',format_type(tt.oid,tt.typtypmod)) as name + FROM pg_cast ca + JOIN pg_type st ON st.oid=castsource + JOIN pg_namespace ns ON ns.oid=st.typnamespace + JOIN pg_type tt ON tt.oid=casttarget + JOIN pg_namespace nt ON nt.oid=tt.typnamespace + LEFT JOIN pg_proc pr ON pr.oid=castfunc + LEFT JOIN pg_namespace np ON np.oid=pr.pronamespace + LEFT OUTER JOIN pg_description des ON (des.objoid=ca.oid AND des.objsubid=0 AND des.classoid='pg_cast'::regclass) + {% if cid %} + WHERE ca.oid={{cid}}::int + {% endif %} + {# Check for Show system object #} + {% if (not showsysobj) and datlastsysoid %} + {% if cid %} + AND + {% else %} + WHERE + {% endif %} + ca.oid > {{datlastsysoid}}::OID + {% endif %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/properties.sql index 15efa95..255ee23 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/casts/templates/cast/sql/9.1_plus/properties.sql @@ -14,7 +14,7 @@ SELECT ca.oid, CASE - WHEN {{datlastsysoid}}::OID > ca.oid then 'Yes' ELSE 'No' + WHEN {{datlastsysoid}}::OID > ca.oid then True ELSE False END AS syscast, CASE WHEN ca.castcontext = 'a' THEN 'ASSIGNMENT' @@ -46,9 +46,8 @@ WHERE ca.oid={{cid}}::int {% endif %} ---TODO: add check for showSystemObject(). currently assumed as false - {# - {% if datlastsysoid %} + {# Check for Show system object #} + {% if (not showsysobj) and datlastsysoid %} {% if cid %} AND {% else %} @@ -56,6 +55,5 @@ {% endif %} ca.oid > {{datlastsysoid}}::OID {% endif %} - #} ORDER BY st.typname, tt.typname {% endif %} \ No newline at end of file
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers