Hi, PFA patch to fix the issue in index or exclusion contrarians node where it was throwing "can't execute an empty query" error due to incorrect validation logic for edit mode. RM#2113
-- Regards, Murtuza Zabuawala EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js index eee9ad2..5972c51 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js @@ -24,7 +24,22 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { },{ id: 'oper_class', label:'{{ _('Operator class') }}', type:'text', node: 'table', url: 'get_oper_class', first_empty: true, - editable: true, + editable: function(m) { + if (m instanceof Backbone.Collection) { + return true; + } else if ((_.has(m.collection, 'handler') && + !_.isUndefined(m.collection.handler) && + !_.isUndefined(m.collection.handler.get('oid')))) { + return false; + } else if (_.has(m.collection, 'handler') && + !_.isUndefined(m.collection.handler) && + !_.isUndefined(m.collection.handler.get('amname')) && + m.collection.handler.get('amname') != 'btree') { + // Disable if access method is not btree + return false; + } + return true; + }, select2: { allowClear: true, width: 'style', tags: true, placeholder: '{{ _("Select the operator class") }}' @@ -65,6 +80,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { url: full_url, success: function(res) { data = res.data; + self.column.set('options', data); }, error: function() { eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); @@ -72,18 +88,6 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { }); eventHandler.trigger('pgadmin:view:fetched', m, self.column); } - /* - * Transform the data - */ - transform = self.column.get('transform') || self.defaults.transform; - if (transform && _.isFunction(transform)) { - // We will transform the data later, when rendering. - // It will allow us to generate different data based on the - // dependencies. - self.column.set('options', transform.bind(self, data)); - } else { - self.column.set('options', data); - } } else { self.column.set('options', []); } @@ -94,49 +98,42 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { options: { onText: 'ASC', offText: 'DESC', - },editable: function(m) { + }, + editable: function(m) { if (m instanceof Backbone.Collection) { return true; - } - else { - if (m.top.get('amname') === 'btree') { - m.set('is_sort_nulls_applicable', true); - return true; - } - m.set('is_sort_nulls_applicable', false); - return false; - } - if ((_.has(m.collection, 'handler') && + } else if ((_.has(m.collection, 'handler') && !_.isUndefined(m.collection.handler) && !_.isUndefined(m.collection.handler.get('oid')))) { return false; + } else if (m.top.get('amname') === 'btree') { + m.set('is_sort_nulls_applicable', true); + return true; + } else { + m.set('is_sort_nulls_applicable', false); + return false; } - return true; } },{ id: 'nulls_order', label:'{{ _('NULLs order') }}', type:"switch", options: { onText: 'FIRST', offText: 'LAST', - },editable: function(m) { + }, + editable: function(m) { if (m instanceof Backbone.Collection) { return true; - } - else { - if (m.top.get('amname') === 'btree') { + } else if ((_.has(m.collection, 'handler') && + !_.isUndefined(m.collection.handler) && + !_.isUndefined(m.collection.handler.get('oid')))) { + return false; + } else if (m.top.get('amname') === 'btree') { m.set('is_sort_nulls_applicable', true); return true; - } + } else { m.set('is_sort_nulls_applicable', false); return false; } - - if ((_.has(m.collection, 'handler') && - !_.isUndefined(m.collection.handler) && - !_.isUndefined(m.collection.handler.get('oid')))) { - return false; - } - return true; } },{ id: 'operator', label:'{{ _('Operator') }}', type: 'text', @@ -184,6 +181,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { url: full_url, success: function(res) { data = res.data; + self.column.set('options', data); }, error: function() { eventHandler.trigger('pgadmin:view:fetch:error', m, self.column); @@ -191,18 +189,6 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) { }); eventHandler.trigger('pgadmin:view:fetched', m, self.column); } - /* - * Transform the data - */ - transform = self.column.get('transform') || self.defaults.transform; - if (transform && _.isFunction(transform)) { - // We will transform the data later, when rendering. - // It will allow us to generate different data based on the - // dependencies. - self.column.set('options', transform.bind(self, data)); - } else { - self.column.set('options', data); - } } } }) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index.js index 249fbaf..e19d054 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/templates/index/js/index.js @@ -84,7 +84,9 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { editable: function(m) { // Header cell then skip if (m instanceof Backbone.Collection) { - return false; + return false; + } else if (m.inSchemaWithModelCheck.apply(this, arguments)) { + return false; } return !(m.checkAccessMethod.apply(this, arguments)); }, @@ -114,12 +116,12 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { // Header cell then skip if (m instanceof Backbone.Collection) { return false; - } - else { - if (m.top.get('amname') === 'btree') { - m.set('is_sort_nulls_applicable', true); - return true; - } + } else if (m.inSchemaWithModelCheck.apply(this, arguments)) { + return false; + } else if (m.top.get('amname') === 'btree') { + m.set('is_sort_nulls_applicable', true); + return true; + } else { m.set('is_sort_nulls_applicable', false); return false; } @@ -136,14 +138,15 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { editable: function(m) { // Header cell then skip if (m instanceof Backbone.Collection) { - return true; - } else { - if (m.top.get('amname') === 'btree') { - m.set('is_sort_nulls_applicable', true); - return true; - } - m.set('is_sort_nulls_applicable', false); return false; + } else if (m.inSchemaWithModelCheck.apply(this, arguments)) { + return false; + } else if (m.top.get('amname') === 'btree') { + m.set('is_sort_nulls_applicable', true); + return true; + } else { + m.set('is_sort_nulls_applicable', false); + return false; } }, deps: ['amname', 'sort_order'], @@ -187,11 +190,10 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { checkAccessMethod: function(m) { //Access method is empty or btree then do not disable field var parent_model = m.top; - if(!m.inSchemaWithModelCheck.apply(this, [m]) && - (_.isUndefined(parent_model.get('amname')) || + if(_.isUndefined(parent_model.get('amname')) || _.isNull(parent_model.get('amname')) || String(parent_model.get('amname')).replace(/^\s+|\s+$/g, '') == '' || - parent_model.get('amname') === 'btree')) { + parent_model.get('amname') === 'btree') { // We need to set nulls to true if sort_order is set to desc // nulls first is default for desc if(m.get('sort_order') == true && m.previous('sort_order') == false) { @@ -202,7 +204,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) { m.set('is_sort_nulls_applicable', false); } return false; - }, + } }); if (!pgBrowser.Nodes['index']) {
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers