Hi,
On Fri, Jul 20, 2018 at 9:31 PM, Dave Page <dp...@pgadmin.org> wrote: > Hi > > On Fri, Jul 20, 2018 at 10:42 AM, Khushboo Vashi < > khushboo.va...@enterprisedb.com> wrote: > >> Hi, >> >> Please find the attached patch to fix the issue : The right panels >> (properties, SQL etc...) give error while clicking on the partitions of a >> table. >> > > This fails tests for me: > Please find the attached patch with fix. Initially we have made partitions as a child of table but later partitions node was brought up to the table level and that was broken. So, I have made it same as initial approach. The jasmine test cases are updated for the same. > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6): Executed 304 of 741 SUCCESS (0 > secs / 4.711 secs) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6) tree#node#getTreeNodeHierarchy > getTreeNodeHierarchy is called with aciTreeNode object When tree has table > when table has partition returns table with partition parameters FAILED > > Expected object not to have properties > > partition: Object({ some key: 'expected value', _type: 'partition', > some other key: 'some other value', priority: 0 }) > > at UserContext.<anonymous> (regression/javascript/tree/ > webpack:/regression/javascript/tree/pgadmin_tree_node_spec.js:177:26) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6): Executed 680 of 741 (1 FAILED) > (0 secs / 6.981 secs) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6) tree#node#getTreeNodeHierarchy > getTreeNodeHierarchy is called with aciTreeNode object When tree has table > when table has partition returns table with partition parameters FAILED > > Expected object not to have properties > > partition: Object({ some key: 'expected value', _type: 'partition', > some other key: 'some other value', priority: 0 }) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6) tree#node#getTreeNodeHierarchy > getTreeNodeHierarchy is called with TreeNode object When tree has table > when table has partition returns table with partition parameters FAILED > > Expected object not to have properties > > partition: Object({ some key: 'expected value', _type: 'partition', > some other key: 'some other value', priority: 0 }) > > at UserContext.<anonymous> (regression/javascript/tree/ > webpack:/regression/javascript/tree/pgadmin_tree_node_spec.js:336:26) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6): Executed 686 of 741 (2 FAILED) > (0 secs / 6.999 secs) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6) tree#node#getTreeNodeHierarchy > getTreeNodeHierarchy is called with TreeNode object When tree has table > when table has partition returns table with partition parameters FAILED > > Expected object not to have properties > > partition: Object({ some key: 'expected value', _type: 'partition', > some other key: 'some other value', priority: 0 }) > > HeadlessChrome 0.0.0 (Mac OS X 10.12.6): Executed 741 of 741 (2 FAILED) > (7.47 secs / 7.149 secs) > > error Command failed with exit code 1. > > info Visit *https://yarnpkg.com/en/docs/cli/run > <https://yarnpkg.com/en/docs/cli/run>* for documentation about this > command. > > make: *** [check] Error 1 > > > -- > 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/schemas/tables/partitions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py index 41b5336..e2fd34c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/__init__.py @@ -240,10 +240,6 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings): else: nodes.extend(module.get_nodes(**kwargs)) - # Explicitly include 'partition' module as we had excluded it during - # registration. - nodes.extend(self.blueprint.get_nodes(**kwargs)) - # Return sorted nodes based on label return make_json_response( data=sorted( diff --git a/web/pgadmin/static/js/tree/pgadmin_tree_node.js b/web/pgadmin/static/js/tree/pgadmin_tree_node.js index 00f10d2..ec59b85 100644 --- a/web/pgadmin/static/js/tree/pgadmin_tree_node.js +++ b/web/pgadmin/static/js/tree/pgadmin_tree_node.js @@ -48,12 +48,13 @@ export function getTreeNodeHierarchyFromIdentifier(aciTreeNodeIdentifier) { export function getTreeNodeHierarchy(currentNode) { let idx = 0; + let node_cnt = 0; let result = {}; do { const currentNodeData = currentNode.getData(); if (currentNodeData._type in this.Nodes && this.Nodes[currentNodeData._type].hasId) { - const nodeType = mapType(currentNodeData._type); + const nodeType = mapType(currentNodeData._type, node_cnt); if (result[nodeType] === undefined) { result[nodeType] = _.extend({}, currentNodeData, { 'priority': idx, @@ -61,12 +62,13 @@ export function getTreeNodeHierarchy(currentNode) { idx -= 1; } } + node_cnt += 1; currentNode = currentNode.hasParent() ? currentNode.parent() : null; } while (currentNode); return result; } -function mapType(type) { - return type === 'partition' ? 'table' : type; +function mapType(type, idx) { + return (type === 'partition' && idx > 0) ? 'table' : type; } diff --git a/web/regression/javascript/tree/pgadmin_tree_node_spec.js b/web/regression/javascript/tree/pgadmin_tree_node_spec.js index 479e515..cfeef69 100644 --- a/web/regression/javascript/tree/pgadmin_tree_node_spec.js +++ b/web/regression/javascript/tree/pgadmin_tree_node_spec.js @@ -178,9 +178,14 @@ describe('tree#node#getTreeNodeHierarchy', () => { 'special one': { 'some key': 'some value', '_type': 'special one', - 'priority': -1, + 'priority': -2, }, 'table': { + 'some key': 'some value', + '_type': 'table', + 'priority': -1, + }, + 'partition': { 'some key': 'expected value', 'some other key': 'some other value', '_type': 'partition', @@ -337,9 +342,14 @@ describe('tree#node#getTreeNodeHierarchy', () => { 'special one': { 'some key': 'some value', '_type': 'special one', - 'priority': -1, + 'priority': -2, }, 'table': { + 'some key': 'some value', + '_type': 'table', + 'priority': -1, + }, + 'partition': { 'some key': 'expected value', 'some other key': 'some other value', '_type': 'partition',