Ensure that all the required options should be loaded when the Range data type

is selected while creating a custom data type.

Fixes #6643
This commit is contained in:
Rahul Shirsat 2021-07-29 10:43:27 +05:30 committed by Akshay Joshi
parent 2452d90300
commit 2dd88e5a4e
3 changed files with 36 additions and 27 deletions

View File

@ -25,3 +25,4 @@ Bug fixes
| `Issue #6580 <https://redmine.postgresql.org/issues/6580>`_ - Fixed TypeError 'NoneType' object is not sub scriptable.
| `Issue #6586 <https://redmine.postgresql.org/issues/6586>`_ - Fixed incorrect tablespace options in the drop-down for move objects dialog.
| `Issue #6619 <https://redmine.postgresql.org/issues/6619>`_ - Fixed incorrect binary path issue when the user deletes the binary path from the preferences.
| `Issue #6643 <https://redmine.postgresql.org/issues/6643>`_ - Ensure that all the required options should be loaded when the Range data type is selected while creating a custom data type.

View File

@ -579,18 +579,18 @@ define('pgadmin.node.type', [
},{
id: 'opcname', label: gettext('Subtype operator class'), cell: 'string',
mode: ['properties', 'create', 'edit'], group: gettext('Range Type'),
disabled: 'inSchema', readonly: 'inEditMode', deps: ['typname'],
control: 'select', options: function() {
var l_typname = this.model.get('typname'),
self = this,
disabled: 'inSchema', readonly: 'inEditMode', deps: ['typname'],
control: 'select2', options: function(control) {
var l_typname = control.model.get('typname'),
result = [];
if(!_.isUndefined(l_typname) && l_typname != '')
{
var node = this.field.get('schema_node'),
var node = control.field.get('schema_node'),
_url = node.generate_url.apply(
node, [
null, 'get_subopclass', this.field.get('node_data'), false,
this.field.get('node_info'),
null, 'get_subopclass', control.field.get('node_data'), false,
control.field.get('node_info'),
]);
$.ajax({
async: false,
@ -602,7 +602,7 @@ define('pgadmin.node.type', [
result = res.data;
})
.fail(function() {
self.model.trigger('pgadmin:view:fetch:error', self.model, self.field);
control.model.trigger('pgadmin:view:fetch:error', control.model, control.field);
});
//
}
@ -640,6 +640,11 @@ define('pgadmin.node.type', [
});
}
// If is_collate is true then do not disable
if(!is_collate) {
m.set({'collname': '', silent: true});
this.options = [];
}
return is_collate ? false : true;
},
},{
@ -647,18 +652,17 @@ define('pgadmin.node.type', [
type: 'text', mode: ['properties', 'create', 'edit'],
group: gettext('Range Type'),
disabled: 'inSchema', readonly: 'inEditMode', deps: ['name', 'typname'],
control: 'select', options: function() {
var name = this.model.get('name'),
self = this,
control: 'select2', options: function(control) {
var name = control.model.get('name'),
result = [];
if(!_.isUndefined(name) && name != '')
{
var node = this.field.get('schema_node'),
var node = control.field.get('schema_node'),
_url = node.generate_url.apply(
node, [
null, 'get_canonical', this.field.get('node_data'), false,
this.field.get('node_info'),
null, 'get_canonical', control.field.get('node_data'), false,
control.field.get('node_info'),
]);
$.ajax({
async: false,
@ -670,8 +674,7 @@ define('pgadmin.node.type', [
result = res.data;
})
.fail(function() {
self.model.trigger('pgadmin:view:fetch:error',
self.model, self.field);
control.model.trigger('pgadmin:view:fetch:error', control.model, control.field);
});
}
return result;
@ -680,21 +683,22 @@ define('pgadmin.node.type', [
id: 'rngsubdiff', label: gettext('Subtype diff function'), cell: 'string',
type: 'text', mode: ['properties', 'create', 'edit'],
group: gettext('Range Type'),
disabled: 'inSchema', readonly: 'inEditMode', deps: ['opcname'],
control: 'select', options: function() {
var l_typname = this.model.get('typname'),
l_opcname = this.model.get('opcname'),
self = this,
disabled: 'inSchema', readonly: 'inEditMode', deps: ['typname', 'opcname'],
control: 'select2', options: function(control) {
var l_typname = control.model.get('typname'),
l_opcname = control.model.get('opcname'),
result = [];
this.options = [];
control.model.set({'rngsubdiff': [], silent: true});
if(!_.isUndefined(l_typname) && l_typname != '' &&
!_.isUndefined(l_opcname) && l_opcname != '') {
var node = this.field.get('schema_node'),
var node = control.field.get('schema_node'),
_url = node.generate_url.apply(
node, [
null, 'get_stypediff',
this.field.get('node_data'), false,
this.field.get('node_info'),
control.field.get('node_data'), false,
control.field.get('node_info'),
]);
$.ajax({
async: false,
@ -706,8 +710,7 @@ define('pgadmin.node.type', [
result = res.data;
})
.fail(function() {
self.model.trigger('pgadmin:view:fetch:error',
self.model, self.field);
control.model.trigger('pgadmin:view:fetch:error', control.model, control.field);
});
}
return result;

View File

@ -29,11 +29,16 @@ SELECT rngsubtype, st.typname,
rngcollation,
CASE WHEN n.nspname IS NOT NULL THEN pg_catalog.concat(pg_catalog.quote_ident(n.nspname), '.', pg_catalog.quote_ident(col.collname)) ELSE col.collname END AS collname,
rngsubopc, opc.opcname,
rngcanonical, rngsubdiff
rngcanonical, rngsubdiff as rngsubdiff_proc,
CASE WHEN length(ns.nspname::text) > 0 AND length(pgpr.proname::text) > 0 THEN
pg_catalog.concat(quote_ident(ns.nspname), '.', pg_catalog.quote_ident(pgpr.proname))
ELSE '' END AS rngsubdiff
FROM pg_catalog.pg_range
LEFT JOIN pg_catalog.pg_type st ON st.oid=rngsubtype
LEFT JOIN pg_catalog.pg_collation col ON col.oid=rngcollation
LEFT JOIN pg_catalog.pg_namespace n ON col.collnamespace=n.oid
LEFT JOIN pg_catalog.pg_opclass opc ON opc.oid=rngsubopc
LEFT JOIN pg_catalog.pg_proc pgpr ON pgpr.oid = rngsubdiff
LEFT JOIN pg_catalog.pg_namespace ns ON ns.oid=pgpr.pronamespace
WHERE rngtypid={{tid}}::oid;
{% endif %}