public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data
@ 2017-05-26 10:12 Murtuza Zabuawala <[email protected]>
  2017-05-26 15:05 ` Re: [pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data Dave Page <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Murtuza Zabuawala @ 2017-05-26 10:12 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

PFA patch to fix the issue in table node,
1) In 'UPDATE Script', '?' is missing with last column.
2) If there are multiple primary keys in table then the order of columns is
incorrect in view data ORDER BY clause.
RM#2417

Also fixed minor issue in Materialized view which I found during testing,
we were not passing database id in properties.sql which is required for
Select and Insert script to work.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

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 54bab0d..99f0ddc 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
@@ -2870,9 +2870,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         if len(columns) > 0:
             if len(columns) == 1:
                 columns = columns[0]
-                columns += "=?"
             else:
                 columns = "=?, ".join(columns)
+            columns += "=?"
 
             sql = u"UPDATE {0}\n\tSET {1}\n\tWHERE <condition>;".format(
                 self.qtIdent(self.conn, data['schema'], data['name']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 0ead437..836018b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -1119,7 +1119,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
             "/".join([
                 self.template_path, 'sql/properties.sql'
             ]),
-            scid=scid, vid=vid,
+            scid=scid, vid=vid, did=did,
             datlastsysoid=self.datlastsysoid
         )
         status, res = self.conn.execute_dict(SQL)
@@ -1180,7 +1180,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
             "/".join([
                 self.template_path, 'sql/properties.sql'
             ]),
-            scid=scid, vid=vid,
+            scid=scid, vid=vid, did=did,
             datlastsysoid=self.datlastsysoid
         )
         status, res = self.conn.execute_dict(SQL)
diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py
index 2bb90c2..9ed9154 100644
--- a/web/pgadmin/tools/sqleditor/command.py
+++ b/web/pgadmin/tools/sqleditor/command.py
@@ -10,7 +10,7 @@
 """ Implemented classes for the different object type used by data grid """
 
 from abc import ABCMeta, abstractmethod
-
+from collections import OrderedDict
 import six
 from flask import render_template
 from flask_babel import gettext
@@ -368,7 +368,7 @@ class TableCommand(GridCommand):
         conn = manager.connection(did=self.did, conn_id=self.conn_id)
 
         pk_names = ''
-        primary_keys = dict()
+        primary_keys = OrderedDict()
 
         if conn.connected():
 


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [text/plain] RM_2417.diff (2.6K, 3-RM_2417.diff)
  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 54bab0d..99f0ddc 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
@@ -2870,9 +2870,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
         if len(columns) > 0:
             if len(columns) == 1:
                 columns = columns[0]
-                columns += "=?"
             else:
                 columns = "=?, ".join(columns)
+            columns += "=?"
 
             sql = u"UPDATE {0}\n\tSET {1}\n\tWHERE <condition>;".format(
                 self.qtIdent(self.conn, data['schema'], data['name']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 0ead437..836018b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -1119,7 +1119,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
             "/".join([
                 self.template_path, 'sql/properties.sql'
             ]),
-            scid=scid, vid=vid,
+            scid=scid, vid=vid, did=did,
             datlastsysoid=self.datlastsysoid
         )
         status, res = self.conn.execute_dict(SQL)
@@ -1180,7 +1180,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
             "/".join([
                 self.template_path, 'sql/properties.sql'
             ]),
-            scid=scid, vid=vid,
+            scid=scid, vid=vid, did=did,
             datlastsysoid=self.datlastsysoid
         )
         status, res = self.conn.execute_dict(SQL)
diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py
index 2bb90c2..9ed9154 100644
--- a/web/pgadmin/tools/sqleditor/command.py
+++ b/web/pgadmin/tools/sqleditor/command.py
@@ -10,7 +10,7 @@
 """ Implemented classes for the different object type used by data grid """
 
 from abc import ABCMeta, abstractmethod
-
+from collections import OrderedDict
 import six
 from flask import render_template
 from flask_babel import gettext
@@ -368,7 +368,7 @@ class TableCommand(GridCommand):
         conn = manager.connection(did=self.did, conn_id=self.conn_id)
 
         pk_names = ''
-        primary_keys = dict()
+        primary_keys = OrderedDict()
 
         if conn.connected():
 


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data
  2017-05-26 10:12 [pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data Murtuza Zabuawala <[email protected]>
@ 2017-05-26 15:05 ` Dave Page <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2017-05-26 15:05 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied (and bugs created for the other two issues).

On Fri, May 26, 2017 at 6:12 AM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi,
>
> PFA patch to fix the issue in table node,
> 1) In 'UPDATE Script', '?' is missing with last column.
> 2) If there are multiple primary keys in table then the order of columns is
> incorrect in view data ORDER BY clause.
> RM#2417
>
> Also fixed minor issue in Materialized view which I found during testing, we
> were not passing database id in properties.sql which is required for Select
> and Insert script to work.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: 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
>



-- 
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




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-05-26 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 10:12 [pgAdmin4] [PATCH] To fix issue in UPDATE Script and Primary key order when view data Murtuza Zabuawala <[email protected]>
2017-05-26 15:05 ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox