mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-09 23:54:09 -06:00
Fixed validation errors in view/materialized view javascript to
determine the number columns chagned. It was trying to execute 'replace' and 'includes' function on undefined values instead of string value. Also - changed the warning message, and separated the 'Do you want to continue?' syntax in separate line for better user experience. Fixes #5053
This commit is contained in:
parent
4c616f32eb
commit
858294f36e
@ -177,7 +177,10 @@ define('pgadmin.node.mview', [
|
||||
Backform.SqlCodeControl.prototype.onChange.apply(this, arguments);
|
||||
if(this.model && this.model.changed) {
|
||||
if(this.model.origSessAttrs && (this.model.changed.definition != this.model.origSessAttrs.definition)) {
|
||||
this.model.warn_text = gettext('Updating the definition will drop and re-create the materialized view. It may result in loss of information about its dependent objects. Do you want to continue?');
|
||||
this.model.warn_text = gettext(
|
||||
'Updating the definition will drop and re-create the materialized view. It may result in loss of information about its dependent objects.'
|
||||
) + '<br><br><b>' + gettext('Do you want to continue?') +
|
||||
'</b>';
|
||||
}
|
||||
else {
|
||||
this.model.warn_text = undefined;
|
||||
|
@ -158,25 +158,42 @@ define('pgadmin.node.view', [
|
||||
control: Backform.SqlCodeControl.extend({
|
||||
onChange: function() {
|
||||
Backform.SqlCodeControl.prototype.onChange.apply(this, arguments);
|
||||
if(this.model && this.model.changed && this.model.node_info.server.server_type == 'pg') {
|
||||
if(this.model.origSessAttrs && (this.model.changed.definition != this.model.origSessAttrs.definition)) {
|
||||
let old_def = this.model.origSessAttrs.definition.replace(/\s/gi, '').split('FROM'),
|
||||
new_def = [];
|
||||
|
||||
if(this.model.changed.definition !== undefined) {
|
||||
new_def = this.model.changed.definition.replace(/\s/gi, '').split('FROM');
|
||||
}
|
||||
if ((old_def.length > 1 || new_def.length > 1) && old_def[0] != new_def[0] && !new_def[0].includes(old_def[0])) {
|
||||
this.model.warn_text = gettext('Changing the columns in a view requires dropping and re-creating the view. This may fail if other objects are dependent upon this view, or may cause procedural functions to fail if they are not modified to take account of the changes. Do you wish to continue?');
|
||||
} else {
|
||||
this.model.warn_text = undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.model.warn_text = undefined;
|
||||
}
|
||||
if (!this.model || !(
|
||||
this.model.changed &&
|
||||
this.model.node_info.server.server_type == 'pg' &&
|
||||
// No need to check this when creating a view
|
||||
this.model.get('oid') !== undefined
|
||||
) || !(
|
||||
this.model.origSessAttrs &&
|
||||
this.model.changed.definition != this.model.origSessAttrs.definition
|
||||
)) {
|
||||
this.model.warn_text = undefined;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
let old_def = this.model.origSessAttrs.definition &&
|
||||
this.model.origSessAttrs.definition.replace(
|
||||
/\s/gi, ''
|
||||
).split('FROM'),
|
||||
new_def = [];
|
||||
|
||||
if (this.model.changed.definition !== undefined) {
|
||||
new_def = this.model.changed.definition.replace(
|
||||
/\s/gi, ''
|
||||
).split('FROM');
|
||||
}
|
||||
|
||||
if ((old_def.length != new_def.length) || (
|
||||
old_def.length > 1 && (
|
||||
old_def[0] != new_def[0]
|
||||
)
|
||||
)) {
|
||||
this.model.warn_text = gettext(
|
||||
'Changing the columns in a view requires dropping and re-creating the view. This may fail if other objects are dependent upon this view, or may cause procedural functions to fail if they are not modified to take account of the changes.'
|
||||
) + '<br><br><b>' + gettext('Do you wish to continue?') +
|
||||
'</b>';
|
||||
} else {
|
||||
this.model.warn_text = undefined;
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user