public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used
@ 2018-03-19 10:07 Murtuza Zabuawala <[email protected]>
2018-03-19 12:38 ` Re: [pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used Dave Page <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Murtuza Zabuawala @ 2018-03-19 10:07 UTC (permalink / raw)
To: pgadmin-hackers
Hi,
PFA patch to fix the issue where pgAdmin4 was not able to utilise the host
parameter from service file.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] RM_3200.diff (3.8K, 3-RM_3200.diff)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index fecb66d..41eb429 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -500,7 +500,7 @@ class ServerNode(PGChildNodeView):
if 'db_res' in data:
data['db_res'] = ','.join(data['db_res'])
- if 'hostaddr' in data and data['hostaddr'] != '':
+ if 'hostaddr' in data and data['hostaddr'] and data['hostaddr'] != '':
if not self.pat4.match(data['hostaddr']):
if not self.pat6.match(data['hostaddr']):
return make_json_response(
@@ -700,7 +700,7 @@ class ServerNode(PGChildNodeView):
)
)
- if 'hostaddr' in data and data['hostaddr'] != '':
+ if 'hostaddr' in data and data['hostaddr'] and data['hostaddr'] != '':
if not self.pat4.match(data['hostaddr']):
if not self.pat6.match(data['hostaddr']):
return make_json_response(
diff --git a/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js b/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js
index 948af3d..f1627aa 100644
--- a/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js
+++ b/web/pgadmin/static/js/browser/server_groups/servers/model_validation.js
@@ -31,6 +31,8 @@ export class ModelValidation {
this.checkForEmpty('name', gettext('Name must be specified.'));
if (ModelValidation.isEmptyString(serviceId)) {
+ // Do not sent empty string
+ this.setNullValueForEmptyString('service');
this.checkHostAndHostAddress();
this.checkForEmpty('db', gettext('Maintenance database must be specified.'));
@@ -50,8 +52,20 @@ export class ModelValidation {
return null;
}
+ setNullValueForEmptyString(field) {
+ let val = this.model.get(field);
+ if (_.isUndefined(val) || _.isNull(val))
+ return;
+
+ // To avoid passing empty string to connection parameter
+ if(String(val).trim() === '') {
+ this.model.set(field, null);
+ }
+ }
+
clearHostAddressAndDbErrors() {
_.each(['host', 'hostaddr', 'db'], (item) => {
+ this.setNullValueForEmptyString(item);
this.model.errorModel.unset(item);
});
}
diff --git a/web/regression/javascript/browser/server_groups/servers/model_validation_spec.js b/web/regression/javascript/browser/server_groups/servers/model_validation_spec.js
index 560d8b6..85e51eb 100644
--- a/web/regression/javascript/browser/server_groups/servers/model_validation_spec.js
+++ b/web/regression/javascript/browser/server_groups/servers/model_validation_spec.js
@@ -20,6 +20,9 @@ describe('Server#ModelValidation', () => {
get: function (key) {
return this.allValues[key];
},
+ set: function (key, value) {
+ this.key = value;
+ },
sessAttrs: {},
};
model.isNew = jasmine.createSpy('isNew');
@@ -51,6 +54,20 @@ describe('Server#ModelValidation', () => {
expect(model.errorModel.set).toHaveBeenCalledWith({});
});
});
+
+ describe('Service id present', () => {
+ it('sets empty service name which should throw an error', () => {
+ model.allValues['service'] = '';
+ expect(modelValidation.validate()).toBe('Either Host name, Address or Service must be specified.');
+ expect(model.errorModel.set).toHaveBeenCalledWith({
+ host: 'Either Host name, Address or Service must be specified.',
+ hostaddr: 'Either Host name, Address or Service must be specified.',
+ db: 'Maintenance database must be specified.'
+ });
+ });
+ });
+
+
});
describe('When no parameters are valid', () => {
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used
2018-03-19 10:07 [pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used Murtuza Zabuawala <[email protected]>
@ 2018-03-19 12:38 ` Dave Page <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2018-03-19 12:38 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Mon, Mar 19, 2018 at 10:07 AM, Murtuza Zabuawala <
[email protected]> wrote:
> Hi,
>
> PFA patch to fix the issue where pgAdmin4 was not able to utilise the host
> parameter from service file.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-03-19 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 10:07 [pgAdmin4][RM#3200] Don't set empty string for host/hostaddr in model when service is used Murtuza Zabuawala <[email protected]>
2018-03-19 12:38 ` 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