public inbox for [email protected]
help / color / mirror / Atom feedFrom: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: RM1119 - Add proper validations in fields before processing
Date: Mon, 8 Aug 2016 14:18:24 +0530
Message-ID: <CAM5-9D_tCLgh23LCKHguNxQrnANQ-rnykK3AdJ3b02er90spEg@mail.gmail.com> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi
Issues fixed:
1) Add proper validation checks for fields.
2) Fixed wrong sql generation due to incorrect conditions in template.
Please find attached patch and review.
Thanks,
Surinder Kumar
--
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] RM1119.patch (4.5K, 3-RM1119.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/js/sequence.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/js/sequence.js
index 474f849..aad76b4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/js/sequence.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/js/sequence.js
@@ -146,7 +146,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
mode: ['properties', 'create', 'edit']
},{
id: 'increment', label: '{{ _('Increment') }}', type: 'int',
- mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}'
+ mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}',
+ min: 1
},{
id: 'start', label: '{{ _('Start') }}', type: 'int',
mode: ['create'], group: '{{ _('Definition') }}'
@@ -161,7 +162,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}'
},{
id: 'cache', label: '{{ _('Cache') }}', type: 'int',
- mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}'
+ mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}',
+ min: 1
},{
id: 'cycled', label: '{{ _('Cycled') }}', type: 'switch',
mode: ['properties', 'create', 'edit'], group: '{{ _('Definition') }}',
@@ -193,11 +195,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
* the GUI for the respective control.
*/
validate: function() {
- var msg = undefined;
+ var msg = undefined,
+ minimum = this.get('minimum'),
+ maximum = this.get('maximum');
+ start = this.get('start');
// Clear any existing error msg.
- this.errorModel.unset('name');
- this.errorModel.unset('seqowner');
- this.errorModel.unset('schema');
+ this.errorModel.clear();
if (_.isUndefined(this.get('name'))
|| String(this.get('name')).replace(/^\s+|\s+$/g, '') == '') {
@@ -219,6 +222,26 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
this.errorModel.set('schema', msg);
return msg;
}
+
+ var min_lt = '{{ _('minimum value must be less than maximum value.') }}',
+ start_lt = '{{ _('start value cannot be less than minimum value.') }}',
+ start_gt = '{{ _('start value cannot be greater than maximum value.') }}';
+ if ((minimum == 0 && maximum == 0) ||
+ (parseInt(minimum, 10) >= parseInt(maximum, 10))) {
+ msg = min_lt
+ this.errorModel.set('minimum', msg);
+ return msg;
+ }
+ else if (start < minimum) {
+ msg = start_lt
+ this.errorModel.set('start', msg);
+ return msg;
+ }
+ else if (start > maximum) {
+ msg = start_gt
+ this.errorModel.set('start', msg);
+ return msg;
+ }
return null;
}
})
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/create.sql
index 23ac1f3..0444a0d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/create.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/create.sql
@@ -3,14 +3,16 @@ CREATE SEQUENCE {{ conn|qtIdent(data.schema) }}.{{ conn|qtIdent(data.name) }}
{% if data.cycled and data.cycled == True %}
CYCLE
{% endif %}
-{% if data.increment %}
+{% if data.increment is defined %}
INCREMENT {{data.increment}}
-{% endif %}{% if data.start %}
+{% endif %}{% if data.start is defined %}
START {{data.start}}
-{% endif %}{% if data.minimum %}
+{% elif data.current_value is defined %}
+ START {{data.current_value}}
+{% endif %}{% if data.minimum is defined %}
MINVALUE {{data.minimum}}
-{% endif %}{% if data.maximum %}
+{% endif %}{% if data.maximum is defined %}
MAXVALUE {{data.maximum}}
-{% endif %}{% if data.cache %}
+{% endif %}{% if data.cache is defined %}
CACHE {{data.cache}}{% endif %};
-{% endif %}
\ No newline at end of file
+{% endif %}
view thread (2+ 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: [pgAdmin4][Patch]: RM1119 - Add proper validations in fields before processing
In-Reply-To: <CAM5-9D_tCLgh23LCKHguNxQrnANQ-rnykK3AdJ3b02er90spEg@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