public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murtuza Zabuawala <[email protected]>
To: Surinder Kumar <[email protected]>
Cc: Harshal Dhumal <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [PATCH] Tables node (pgAdmin4)
Date: Tue, 17 May 2016 14:52:13 +0530
Message-ID: <CAKKotZQPLM-9t_WjJfWqdaLfkj9LkopUR3RgoCTbBBB0NBaHdg@mail.gmail.com> (raw)
In-Reply-To: <CAM5-9D_nJjALb9xvgf8pZtm7RLa86VOxf_6UQF1rh-YAxFk7ew@mail.gmail.com>
References: <CAKKotZRCf07F_SGHi4KawBtLHPSeKz5Uvzwu6ddQ=bKc1FDRRw@mail.gmail.com>
<CAFiP3vw61T0n--F4vYXALdtrkBKznBegBPq5Ds=6uZrg02vWXQ@mail.gmail.com>
<CAFOhELea6nCtX_T78o_3mNKJC0_emirXKGm3nq8d6mvSZV57pg@mail.gmail.com>
<CAFiP3vypf7KEmToKsBqn1--qf_PzMV+p-d9bsMj04eoYnj5_tQ@mail.gmail.com>
<CAKKotZQumWW_cvhvgyFc7_1Lvs8npkPW57FgVN_+wPPSurBDOw@mail.gmail.com>
<CAKKotZQMR5zsbDAiAhUEQ46yhNE51BONu0DYjEY1WFSJbBqK+w@mail.gmail.com>
<CAFiP3vwBUX5Ez51Fk_s+t67hRW-uZ6ViMcuTg4e+oPf+k5KqTg@mail.gmail.com>
<CAFOhELdg9-TB=fdpGDLNkjYve9vBxYttE_PzmahsrNMQv4nn4Q@mail.gmail.com>
<CAFiP3vxO9tej3WXYeLjZk6MgQYR0C-hp9UUWmog1E7iDvvqFmQ@mail.gmail.com>
<CAFOhELd=_vuqwR0eGLL=KhxGaQCP6n9mcXP1GijcWh1ecCpegw@mail.gmail.com>
<CAFiP3vw5nx2Wdt9ci-MNRV+H+dO-x9KUSZtk16EZKjdox+KRxg@mail.gmail.com>
<CAFiP3vz9=gtNuoGEt+oxt+UYfE=7=dTUQZpCxgGkVWUhS=Kafw@mail.gmail.com>
<CAM5-9D_nJjALb9xvgf8pZtm7RLa86VOxf_6UQF1rh-YAxFk7ew@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi,
PFA add-on patch to Ver.6 patch, Which will add CREATE/SELECT etc Script
support into table node.
Regards,
Murtuza
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, May 17, 2016 at 11:48 AM, Surinder Kumar <
[email protected]> wrote:
> Hi,
>
> Please find attached add-on patch for table's subnode rule.
> Apply this patch at end after applying previous patches in email thread.
>
> *Issue fixed*: "Do Instead" on Rule node under View/M-View node not
> working in properties mode. Unable to generate proper SQL.
>
> On Mon, May 16, 2016 at 7:02 PM, Harshal Dhumal <
> [email protected]> wrote:
>
>> Hi,
>>
>> PFA add-on patch for table and it's child node. (please apply this patch
>> on version 6 patch)
>>
>> Murtuza and I fixed following issues:
>>
>> 1. SQL formatting
>> 2. Vacuum grid should not be editable in properties mode.
>> 3. Column datatype does not get displayed in the properties and edit mode.
>> 4. Do not allow to add another primary key if one already exist.
>>
>> And another minor enhancements.
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer *
>>
>>
>>
>> EenterpriseDB <http://www.enterprisedb.com;
>>
>> On Sat, May 14, 2016 at 2:03 AM, Harshal Dhumal <
>> [email protected]> wrote:
>>
>>>
>>> Hi,
>>>
>>>
>>> PFA updated patches (version: 6) for table and it's child nodes.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer *
>>>
>>>
>>>
>>> EenterpriseDB <http://www.enterprisedb.com;
>>>
>>> On Fri, May 13, 2016 at 6:55 PM, Khushboo Vashi <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> Review Comments:
>>>>
>>>> - Please replace 'can not' with 'cannot' in all the validation
>>>> messages.
>>>> - PG 9.1+ Inheritance issue as below:
>>>>
>>>> CREATE TABLE public.table1
>>>> (
>>>> )
>>>> (
>>>> )
>>>> INHERITS (a)
>>>> WITH (
>>>> OIDS = FALSE
>>>> )
>>>> TABLESPACE pg_default;
>>>> ALTER TABLE public.table1
>>>> OWNER to postgres;
>>>>
>>>>
>>>> brackets are coming twice.
>>>>
>>> Fixed
>>>
>>>
>>>>
>>>> - Please maintain one line spacing between SQL queries In the SQL Tab.
>>>>
>>> TODO
>>>
>>>
>>>> - Foreign Key Grid in Table css issue: Grid columns expands on the
>>>> selection of the cell
>>>>
>>> Fixed
>>>
>>>
>>>> - Check Constraint: Validated? option should be True by default
>>>>
>>> Not sure about this. I cross checked in pgadmin3.
>>>
>>>
>>>
>>>> - pg 9.4: Exclude constraint does not render in SQL tab
>>>>
>>> Fixed
>>>
>>>
>>>> - Missing Security validation
>>>>
>>> Fixed
>>>
>>>
>>>> - Vacuum grid should not be editable in properties mode.
>>>>
>>> TODO (It's editable but one cannot save it on server from here as there
>>> is no save button.)
>>>
>>>
>>>> - Edit mode, Fill Factor can be allowed to be null.
>>>>
>>> TODO (This is generic issue in Integer and Numeric controls. This issue
>>> is covered in this partial patch
>>> <http://www.postgresql.org/message-id/[email protected]....;
>>> )
>>>
>>>
>>>> - While dropping inheritance, related table columns drop SQL are also
>>>> populated in the SQL Tab
>>>>
>>>> ALTER TABLE public."Tbl"
>>>> NO INHERIT b;
>>>> ALTER TABLE public."Tbl" DROP COLUMN id;
>>>> ALTER TABLE public."Tbl" DROP COLUMN name;
>>>>
>>>>
>>> Fixed
>>>
>>>
>>>
>>>>
>>>> And also render error while clicking on the save button.
>>>>
>>>> ERROR: syntax error at or near "["
>>>> LINE 2: INHERIT [;
>>>>
>>>> ^
>>>>
>>>> Fixed
>>>
>>>
>>>> - in a Reverse Engineering SQL tab, schema_name.tablename should be
>>>> there, currently only table_name displays.
>>>>
>>> Fixed
>>>
>>>
>>>
>>>> - Column SQL is showing below text with HTML
>>>>
>>>>
>>>> <html><head></head><body>-- Column: id -- ALTER TABLE public.a DROIP
>>>> COLUMN id; ALTER TABLE public.a ADD COLUMN id integer;</body></html>
>>>>
>>>>
>>> I was not able to reproduce exact issue but still I have fixed other
>>> issue which I found related to column SQL. Hopefully that will fix this
>>> issue as well.
>>>
>>>
>>>> - The column datatype dependency does not get cleared upon selection of
>>>> another datatype.
>>>>
>>> For example, if I select numeric and gives the length and precision.
>>>> After that I change the dat-type then, dependent fields should be get
>>>> cleared.
>>>>
>>> Fixed.
>>>
>>>
>>>>
>>>> - The column datatype does not get displayed in the properties and edit
>>>> mode if the length and precision are given while creating a column.
>>>>
>>>
>>> TODO ( I cannot fix this blindly as this might introduce another
>>> issue(s) in column node. I will need Murtuza's help as he has worked on
>>> column node)
>>>
>>>
>>>>
>>>> - Statistics is showing null value even after having value.
>>>>
>>> Fixed
>>>
>>>
>>>>
>>>> - if the check constraints are not validated then put proper icon in
>>>> tree and also it should be validated in edit mode.
>>>>
>>> Not reproducible.
>>>
>>>
>>>>
>>>> NOTE: I have not checked the Indexes, Triggers and Rules nodes as I do
>>>> not have much knowledge about it.
>>>>
>>>>
>>>
>>>
>>>> Thanks,
>>>> Khushboo
>>>>
>>>> On Fri, May 13, 2016 at 5:24 PM, Harshal Dhumal <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> PFA attached patches for table and it's child nodes with python 2.7
>>>>> compatibility.
>>>>>
>>>>>
>>>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list ([email protected])
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] Added_CREATE_Script_on_Table_v8.patch (7.9K, 3-Added_CREATE_Script_on_Table_v8.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index c561159..adf7001 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -197,6 +197,18 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
* get_index_constraint_sql(self, tid, data):
- This function will generate modified sql for index constraints
(Primary Key & Unique)
+
+ * select_sql(gid, sid, did, scid, foid):
+ - Returns sql for Script
+
+ * insert_sql(gid, sid, did, scid, foid):
+ - Returns sql for Script
+
+ * update_sql(gid, sid, did, scid, foid):
+ - Returns sql for Script
+
+ * delete_sql(gid, sid, did, scid, foid):
+ - Returns sql for Script
"""
node_type = blueprint.node_type
@@ -238,7 +250,12 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
'all_tables': [{}, {'get': 'get_all_tables'}],
'get_access_methods': [{}, {'get': 'get_access_methods'}],
'get_oper_class': [{}, {'get': 'get_oper_class'}],
- 'get_operator': [{}, {'get': 'get_operator'}]
+ 'get_operator': [{}, {'get': 'get_operator'}],
+ 'select_sql': [{'get': 'select_sql'}],
+ 'insert_sql': [{'get': 'insert_sql'}],
+ 'update_sql': [{'get': 'update_sql'}],
+ 'delete_sql': [{'get': 'delete_sql'}]
+
})
def check_precondition(f):
@@ -2629,4 +2646,176 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
return ajax_response(response=sql.strip('\n'))
+ @check_precondition
+ def select_sql(self, gid, sid, did, scid, tid):
+ """
+ SELECT script sql for the object
+
+ Args:
+ gid: Server Group Id
+ sid: Server Id
+ did: Database Id
+ scid: Schema Id
+ tid: Table Id
+
+ Returns:
+ SELECT Script sql for the object
+ """
+ SQL = render_template("/".join([self.template_path,
+ 'properties.sql']),
+ scid=scid, tid=tid,
+ datlastsysoid=self.datlastsysoid)
+ status, res = self.conn.execute_dict(SQL)
+ if not status:
+ return internal_server_error(errormsg=res)
+
+ data = res['rows'][0]
+ data = self._formatter(scid, tid, data)
+
+ columns = []
+
+ # Now we have all list of columns which we need
+ if 'columns' in data:
+ for c in data['columns']:
+ columns.append(self.qtIdent(self.conn, c['attname']))
+
+ if len(columns) > 0:
+ columns = ", ".join(columns)
+ else:
+ columns = '*'
+
+ sql = "SELECT {0}\n\tFROM {1};".format(
+ columns,
+ self.qtIdent(self.conn, data['schema'], data['name'])
+ )
+ return ajax_response(response=sql)
+
+ @check_precondition
+ def insert_sql(self, gid, sid, did, scid, tid):
+ """
+ INSERT script sql for the object
+
+ Args:
+ gid: Server Group Id
+ sid: Server Id
+ did: Database Id
+ scid: Schema Id
+ tid: Table Id
+
+ Returns:
+ INSERT Script sql for the object
+ """
+ SQL = render_template("/".join([self.template_path,
+ 'properties.sql']),
+ scid=scid, tid=tid,
+ datlastsysoid=self.datlastsysoid)
+ status, res = self.conn.execute_dict(SQL)
+ if not status:
+ return internal_server_error(errormsg=res)
+
+ data = res['rows'][0]
+ data = self._formatter(scid, tid, data)
+
+ columns = []
+ values = []
+
+ # Now we have all list of columns which we need
+ if 'columns' in data:
+ for c in data['columns']:
+ columns.append(self.qtIdent(self.conn, c['attname']))
+ values.append('?')
+
+ if len(columns) > 0:
+ columns = ", ".join(columns)
+ values = ", ".join(values)
+ sql = "INSERT INTO {0}(\n\t{1})\n\tVALUES ({2});".format(
+ self.qtIdent(self.conn, data['schema'], data['name']),
+ columns, values
+ )
+ else:
+ sql = gettext('-- Please create column(s) first...')
+
+ return ajax_response(response=sql)
+
+ @check_precondition
+ def update_sql(self, gid, sid, did, scid, tid):
+ """
+ UPDATE script sql for the object
+
+ Args:
+ gid: Server Group Id
+ sid: Server Id
+ did: Database Id
+ scid: Schema Id
+ tid: Table Id
+
+ Returns:
+ UPDATE Script sql for the object
+ """
+ SQL = render_template("/".join([self.template_path,
+ 'properties.sql']),
+ scid=scid, tid=tid,
+ datlastsysoid=self.datlastsysoid)
+ status, res = self.conn.execute_dict(SQL)
+ if not status:
+ return internal_server_error(errormsg=res)
+
+ data = res['rows'][0]
+ data = self._formatter(scid, tid, data)
+
+ columns = []
+
+ # Now we have all list of columns which we need
+ if 'columns' in data:
+ for c in data['columns']:
+ columns.append(self.qtIdent(self.conn, c['attname']))
+
+ if len(columns) > 0:
+ if len(columns) == 1:
+ columns = columns[0]
+ columns += "=?"
+ else:
+ columns = "=?, ".join(columns)
+
+ sql = "UPDATE {0}\n\tSET {1}\n\tWHERE <condition>;".format(
+ self.qtIdent(self.conn, data['schema'], data['name']),
+ columns
+ )
+ else:
+ sql = gettext('-- Please create column(s) first...')
+
+ return ajax_response(response=sql)
+
+ @check_precondition
+ def delete_sql(self, gid, sid, did, scid, tid):
+ """
+ DELETE script sql for the object
+
+ Args:
+ gid: Server Group Id
+ sid: Server Id
+ did: Database Id
+ scid: Schema Id
+ tid: Table Id
+
+ Returns:
+ DELETE Script sql for the object
+ """
+ SQL = render_template("/".join([self.template_path,
+ 'properties.sql']),
+ scid=scid, tid=tid,
+ datlastsysoid=self.datlastsysoid)
+ status, res = self.conn.execute_dict(SQL)
+ if not status:
+ return internal_server_error(errormsg=res)
+
+ data = res['rows'][0]
+
+ sql = "DELETE FROM {0}\n\tWHERE <condition>;".format(
+ self.qtIdent(self.conn, data['schema'], data['name'])
+ )
+
+ return ajax_response(response=sql)
+
+
TableView.register_node_view(blueprint)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
index 0258ca7..ffe3124 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/js/table.js
@@ -26,6 +26,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
sqlAlterHelp: 'sql-altertable.html',
sqlCreateHelp: 'sql-createtable.html',
parent_type: ['schema', 'catalog'],
+ hasScriptTypes: ['create', 'select', 'insert', 'update', 'delete'],
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
view thread (49+ 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], [email protected]
Subject: Re: [PATCH] Tables node (pgAdmin4)
In-Reply-To: <CAKKotZQPLM-9t_WjJfWqdaLfkj9LkopUR3RgoCTbBBB0NBaHdg@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