public inbox for [email protected]
help / color / mirror / Atom feedFrom: Akshay Joshi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM4633] Bad view in partitioned tables
Date: Fri, 3 Jan 2020 16:58:36 +0530
Message-ID: <CANxoLDcU_NqABtQA2H5zsFjK6Pb8evdGOBoNGxekvx9KroRmow@mail.gmail.com> (raw)
Hi Hackers
Attached is the patch to support the view part of the multilevel
partitions. Users can perform all the operations except creating the
partitions as a partitioned table. Users can create a partition table
separately and attach it as a partition of another partition table.
There are two problems mentioned in the RM. I have fixed the first one and
we won't fix the second problem as by design we decided to show Partitions
like Schema->Table->Partitions
Please review it.
--
*Thanks & Regards*
*Akshay Joshi*
*Sr. Software Architect*
*EnterpriseDB Software India Private Limited*
*Mobile: +91 976-788-8246*
Attachments:
[application/octet-stream] RM_4633.patch (9.6K, 3-RM_4633.patch)
download | inline diff:
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 11180ad85..72dbb5d24 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
@@ -200,52 +200,27 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings):
})
- def children(self, **kwargs):
- """Build a list of treeview nodes from the child nodes."""
-
- if 'sid' not in kwargs:
- return precondition_required(
- gettext('Required properties are missing.')
- )
-
- from pgadmin.utils.driver import get_driver
- manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
- sid=kwargs['sid']
- )
-
- did = None
- if 'did' in kwargs:
- did = kwargs['did']
-
- conn = manager.connection(did=did)
-
- if not conn.connected():
- return precondition_required(
- gettext(
- "Connection to the server has been lost."
- )
- )
-
+ def _get_children_nodes(self, manager, **kwargs):
nodes = []
+ # treat partition table as normal table.
+ # replace tid with ptid and pop ptid from kwargs
+ if 'ptid' in kwargs:
+ ptid = kwargs.pop('ptid')
+ kwargs['tid'] = ptid
+
for module in self.blueprint.submodules:
if isinstance(module, PGChildModule):
if manager is not None and \
module.BackendSupported(manager, **kwargs):
- # treat partition table as normal table.
- # replace tid with ptid and pop ptid from kwargs
- if 'ptid' in kwargs:
- ptid = kwargs.pop('ptid')
- kwargs['tid'] = ptid
nodes.extend(module.get_nodes(**kwargs))
else:
nodes.extend(module.get_nodes(**kwargs))
- # Return sorted nodes based on label
- return make_json_response(
- data=sorted(
- nodes, key=lambda c: c['label']
- )
- )
+ if manager is not None and \
+ self.blueprint.BackendSupported(manager, **kwargs):
+ nodes.extend(self.blueprint.get_nodes(**kwargs))
+
+ return nodes
@BaseTableView.check_precondition
def list(self, gid, sid, did, scid, tid):
@@ -295,7 +270,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings):
"""
SQL = render_template(
"/".join([self.partition_template_path, 'nodes.sql']),
- scid=scid, tid=tid
+ scid=scid, tid=tid, ptid=ptid
)
status, rset = self.conn.execute_2darray(SQL)
if not status:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
index 14e015210..04a693ead 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js
@@ -49,8 +49,7 @@ function(
sqlCreateHelp: 'sql-createtable.html',
dialogHelp: url_for('help.static', {'filename': 'table_dialog.html'}),
hasScriptTypes: ['create'],
- height: '95%',
- width: '85%',
+ width: '650px',
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)
@@ -865,7 +864,7 @@ function(
canEdit: false, canDelete: true,
customDeleteTitle: gettext('Detach Partition'),
customDeleteMsg: gettext('Are you sure you wish to detach this partition?'),
- columns:['is_attach', 'partition_name', 'values_from', 'values_to', 'values_in'],
+ columns:['is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder'],
control: Backform.SubNodeCollectionControl.extend({
row: Backgrid.PartitionRow,
initialize: function() {
@@ -930,10 +929,30 @@ function(
},{
id: 'partition_note', label: gettext('Partition'),
type: 'note', group: 'partition',
- text: gettext('The control above is used to Create/Attach/Detach partitions.<br>' +
- '<ul><li>Create Mode: User will be able to create N number of partitions. Mode switch control is disabled in this scenario.</li>' +
- '<li>Edit Mode: User will be able to create/attach/detach N number of partitions. ' +
- 'In attach mode there will be list of suitable tables to be attached.</li></ul>'),
+ text: [
+ '<ul><li>',
+ '<strong>', gettext('Create a table: '), '</strong>',
+ gettext('User can create multiple partitions while creating new partitioned table. Operation switch is disabled in this scenario.'),
+ '</li><li>',
+ '<strong>', gettext('Edit existing table: '), '</strong>',
+ gettext('User can create/attach/detach multiple partitions. In attach operation user can select table from the list of suitable tables to be attached.'),
+ '</li><li>',
+ '<strong>', gettext('Default: '), '</strong>',
+ gettext('The default partition can store rows that do not fall into any existing partition’s range or list.'),
+ '</li><li>',
+ '<strong>', gettext('From/To/In input: '), '</strong>',
+ gettext('From/To/In input: Values for these fields must be quoted with single quote. For more than one partition key values must be comma(,) separated.'),
+ '</li><li>',
+ '<strong>', gettext('Example: From/To: '), '</strong>',
+ gettext('Enabled for range partition. Consider partitioned table with multiple keys of type Integer, then values should be specified like \'100\',\'200\'.'),
+ '</li><li>',
+ '<strong>', gettext('In: '), '</strong>',
+ gettext('Enabled for list partition. Values must be comma(,) separated and quoted with single quote.'),
+ '</li><li>',
+ '<strong>', gettext('Modulus/Remainder: '), '</strong>',
+ gettext('Enabled for hash partition.'),
+ '</li></ul>',
+ ].join(''),
visible: function(m) {
if(!_.isUndefined(m.node_info) && !_.isUndefined(m.node_info.server)
&& !_.isUndefined(m.node_info.server.version) &&
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index 0cc061db5..b7c8d2945 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -343,10 +343,8 @@ class NodeView(with_metaclass(MethodViewType, View)):
def children(self, *args, **kwargs):
"""Build a list of treeview nodes from the child nodes."""
- children = []
+ children = self._get_children_nodes(*args, **kwargs)
- for module in self.blueprint.submodules:
- children.extend(module.get_nodes(*args, **kwargs))
# Return sorted nodes based on label
return make_json_response(
data=sorted(
@@ -354,8 +352,46 @@ class NodeView(with_metaclass(MethodViewType, View)):
)
)
+ def _get_children_nodes(self, *args, **kwargs):
+ """
+ Returns the list of children nodes for the current nodes. Override this
+ function for special cases only.
+
+ :param args:
+ :param kwargs: Parameters to generate the correct set of tree node.
+ :return: List of the children nodes
+ """
+ children = []
+
+ for module in self.blueprint.submodules:
+ children.extend(module.get_nodes(*args, **kwargs))
+
+ return children
+
class PGChildNodeView(NodeView):
+
+ def _get_children_nodes(self, manager, **kwargs):
+ """
+ Returns the list of children nodes for the current nodes.
+
+ :param manager: Server Manager object
+ :param kwargs: Parameters to generate the correct set of browser tree
+ node
+ :return:
+ """
+ nodes = []
+ for module in self.blueprint.submodules:
+ if isinstance(module, PGChildModule):
+ if (
+ manager is not None and
+ module.BackendSupported(manager, **kwargs)
+ ):
+ nodes.extend(module.get_nodes(**kwargs))
+ else:
+ nodes.extend(module.get_nodes(**kwargs))
+ return nodes
+
def children(self, **kwargs):
"""Build a list of treeview nodes from the child nodes."""
@@ -388,21 +424,11 @@ class PGChildNodeView(NodeView):
)
)
- nodes = []
- for module in self.blueprint.submodules:
- if isinstance(module, PGChildModule):
- if (
- manager is not None and
- module.BackendSupported(manager, **kwargs)
- ):
- nodes.extend(module.get_nodes(**kwargs))
- else:
- nodes.extend(module.get_nodes(**kwargs))
-
# Return sorted nodes based on label
return make_json_response(
data=sorted(
- nodes, key=lambda c: c['label']
+ self._get_children_nodes(manager, **kwargs),
+ key=lambda c: c['label']
)
)
view thread (3+ 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]
Subject: Re: [pgAdmin][RM4633] Bad view in partitioned tables
In-Reply-To: <CANxoLDcU_NqABtQA2H5zsFjK6Pb8evdGOBoNGxekvx9KroRmow@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