diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py index 647af85a7..14b9f9d15 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py @@ -1185,9 +1185,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare): data['change_func'] = False for arg in fun_change_args: - if arg == 'arguments' and arg in data and len(data[arg]) > 0: - data['change_func'] = True - elif arg in data: + if (arg == 'arguments' and arg in data and len(data[arg]) > 0)\ + or arg in data: data['change_func'] = True # If Function Definition/Arguments are changed then merge old diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js index f606e384f..ff2c2d2c1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.js @@ -233,11 +233,8 @@ define('pgadmin.node.schema', [ disabled: function(m) { // We need to check additional condition to toggle enable/disable // for table auto-vacuum - if(!m.top.inSchema.apply(this, [m]) && m.isNew()) { - return false; - } else if(!m.top.inSchema.apply(this, [m]) && - (m.get('toast_autovacuum_enabled') === true || - m.top.get('hastoasttable') === true)) { + if(!m.top.inSchema.apply(this, [m]) && + (m.isNew() || (m.get('toast_autovacuum_enabled') === true || m.top.get('hastoasttable') === true))) { return false; } return true; diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/utils.py index 77a163f97..05e2c1b10 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/utils.py @@ -164,9 +164,8 @@ def get_sql(conn, data, tid, cid=None, template_path=None): sql = render_template("/".join([template_path, 'update.sql']), data=data, o_data=old_data, conn=conn) else: - if 'consrc' not in data: - return _('-- definition incomplete'), name - elif isinstance(data['consrc'], list) and len(data['consrc']) < 1: + if 'consrc' not in data or \ + (isinstance(data['consrc'], list) and len(data['consrc']) < 1): return _('-- definition incomplete'), name sql = render_template("/".join([template_path, 'create.sql']), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py index 255d85edf..13fb54663 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py @@ -496,15 +496,8 @@ class ExclusionConstraintView(PGChildNodeView): data[k] = v for arg in required_args: - if arg not in data: - return make_json_response( - status=400, - success=0, - errormsg=_( - "Could not find required parameter ({})." - ).format(arg) - ) - elif isinstance(data[arg], list) and len(data[arg]) < 1: + if arg not in data or \ + (isinstance(data[arg], list) and len(data[arg]) < 1): return make_json_response( status=400, success=0, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/utils.py index 1db68c81b..826325450 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/utils.py @@ -204,9 +204,9 @@ def get_sql(conn, data, did, tid, exid=None, template_path=None): sql = render_template("/".join([template_path, 'update.sql']), data=data, o_data=old_data) else: - if 'columns' not in data: - return _('-- definition incomplete'), name - elif isinstance(data['columns'], list) and len(data['columns']) < 1: + if 'columns' not in data or \ + (isinstance(data['columns'], list) and + len(data['columns']) < 1): return _('-- definition incomplete'), name sql = render_template("/".join([template_path, 'create.sql']), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py index 6d0ff2c1a..19d01c196 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py @@ -513,15 +513,8 @@ class ForeignKeyConstraintView(PGChildNodeView): data[k] = v for arg in required_args: - if arg not in data: - return make_json_response( - status=400, - success=0, - errormsg=gettext( - "Could not find required parameter ({})." - ).format(arg) - ) - elif isinstance(data[arg], list) and len(data[arg]) < 1: + if arg not in data or \ + (isinstance(data[arg], list) and len(data[arg]) < 1): return make_json_response( status=400, success=0, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/utils.py index 027f39dc1..47399bed7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/utils.py @@ -263,9 +263,9 @@ def get_sql(conn, data, tid, fkid=None, template_path=None): "/".join([template_path, 'create_index.sql']), data=data, conn=conn) else: - if 'columns' not in data: - return _('-- definition incomplete'), name - elif isinstance(data['columns'], list) and len(data['columns']) < 1: + if 'columns' not in data or \ + (isinstance(data['columns'], list) and + len(data['columns']) < 1): return _('-- definition incomplete'), name if data['autoindex'] and \ diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py index c028bc978..019096e06 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py @@ -1057,16 +1057,14 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare): for key in required_create_keys: if key in diff_dict: - if key == 'columns' and (( + if (key == 'columns' and (( 'added' in diff_dict[key] and len(diff_dict[key]['added']) > 0 ) or ('changed' in diff_dict[key] and len(diff_dict[key]['changed']) > 0) or ( 'deleted' in diff_dict[key] and len(diff_dict[key]['deleted']) > 0) - ): - create_req = True - elif key != 'columns': + )) or key != 'columns': create_req = True if create_req: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js index 2bf0484c6..91027e156 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.js @@ -99,9 +99,7 @@ define('pgadmin.node.index', [ type: 'text', disabled: 'checkAccessMethod', editable: function(m) { // Header cell then skip - if (m instanceof Backbone.Collection) { - return false; - } else if (m.inSchemaWithModelCheck.apply(this, arguments)) { + if (m instanceof Backbone.Collection || m.inSchemaWithModelCheck.apply(this, arguments)) { return false; } return !(m.checkAccessMethod.apply(this, arguments)); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js index 5f1c4c569..5fe213617 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.js @@ -134,9 +134,7 @@ define('pgadmin.node.rule', [ if (m && m.get('name') == '_RETURN') { return true; } - if (m.isNew()) { - return false; - } else if (m.node_info.server.version >= 90400) { + if (m.isNew() || m.node_info.server.version >= 90400) { return false; } return true; diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index d7cb3b710..b96298283 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -1129,7 +1129,7 @@ define([ // Check if unique columns provided are also in model attributes. if (uniqueCol.length > _.intersection(columns, uniqueCol).length) { var errorMsg = 'Developer: Unique columns [ ' + _.difference(uniqueCol, columns) + ' ] not found in collection model [ ' + columns + ' ].'; - alert(errorMsg); + throw errorMsg; } var collection = self.collection = self.model.get(self.field.get('name')); diff --git a/web/regression/python_test_utils/template_helper.py b/web/regression/python_test_utils/template_helper.py index 0ab9454e9..56fd6ac98 100644 --- a/web/regression/python_test_utils/template_helper.py +++ b/web/regression/python_test_utils/template_helper.py @@ -25,6 +25,7 @@ class SimpleTemplateLoader(BaseLoader): def file_as_template(file_path): """This method returns a jinja template for the given filepath """ file_content = open(file_path, 'r').read() - env = Environment(loader=SimpleTemplateLoader(file_content)) + env = Environment(loader=SimpleTemplateLoader(file_content), + autoescape=True) template = env.get_template("") return template