From a0010aac318cb65303680fa2d86212a898794641 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 25 Mar 2019 14:29:43 +0530 Subject: [PATCH] 1) Ensure that sequence should be created with Privileges. 2) Updated the validation for blank values in Definition tab. --- .../servers/databases/schemas/sequences/__init__.py | 2 +- .../schemas/sequences/static/js/sequence.js | 3 +++ .../templates/sequence/sql/default/create.sql | 12 ++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py index d621dc0be..56b2a676e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py @@ -364,7 +364,7 @@ class SequenceView(PGChildNodeView): return internal_server_error(errormsg=msg) if 'relacl' in data: - data['relacl'] = parse_priv_to_db(data['relacl'], 'DATABASE') + data['relacl'] = parse_priv_to_db(data['relacl'], self.acl) # The SQL below will execute rest DMLs because we cannot execute # CREATE with any other diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js index 8bdb52903..8340d9017 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.js @@ -262,6 +262,9 @@ define('pgadmin.node.sequence', [ start_lt = gettext('Start value cannot be less than minimum value.'), start_gt = gettext('Start value cannot be greater than maximum value.'); + if (_.isEmpty(minimum) || _.isEmpty(maximum)) + return null; + if ((minimum == 0 && maximum == 0) || (parseInt(minimum, 10) >= parseInt(maximum, 10))) { this.errorModel.set('minimum', min_lt); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/default/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/default/create.sql index 446559900..61e34c645 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/default/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/default/create.sql @@ -1,16 +1,16 @@ CREATE SEQUENCE {{ conn|qtIdent(data.schema, data.name) }}{% if data.increment is defined and data.cycled %} - CYCLE{% endif %}{% if data.increment is defined %} + CYCLE{% endif %}{% if data.increment is defined and data.increment|int(-1) > -1 %} - INCREMENT {{data.increment|int}}{% endif %}{% if data.start is defined %} + INCREMENT {{data.increment|int}}{% endif %}{% if data.start is defined and data.start|int(-1) > -1%} - START {{data.start|int}}{% elif data.current_value is defined %} + START {{data.start|int}}{% elif data.current_value is defined and data.current_value|int(-1) > -1%} - START {{data.current_value|int}}{% endif %}{% if data.minimum is defined %} + START {{data.current_value|int}}{% endif %}{% if data.minimum is defined and data.minimum|int(-1) > -1%} - MINVALUE {{data.minimum|int}}{% endif %}{% if data.maximum is defined %} + MINVALUE {{data.minimum|int}}{% endif %}{% if data.maximum is defined and data.maximum|int(-1) > -1%} - MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined %} + MAXVALUE {{data.maximum|int}}{% endif %}{% if data.cache is defined and data.cache|int(-1) > -1%} CACHE {{data.cache|int}}{% endif %};