Hi, PFA patch to address below, 1) Allow user to create ENUM type without any labels. 2) Allow user to add new label to existing enum type which do not have any existing labels. RM#2426
-- Regards, Murtuza Zabuawala EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py index 031e1b7..9c88c63 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py @@ -905,16 +905,6 @@ class TypeView(PGChildNodeView, DataTypeReader): 'Composite types require at least two members.' ) ) - # If type is enum then check if it has minimum one label - if data and data[arg] == 'e': - if len(data['enum']) < 1: - return make_json_response( - status=410, - success=0, - errormsg=gettext( - 'Enumeration types require at least one label.' - ) - ) # If type is range then check if subtype is defined or not if data and data[arg] == 'r': if data['typname'] is None: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js index 9a195e6..4c101fd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/js/type.js @@ -241,18 +241,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backgrid) { } }], validate: function() { - var err = {}, - errmsg = null; - - if (_.isUndefined(this.get('label') || - _.isNull(this.get('label')) || - String(this.get('label')).replace(/^\s+|\s+$/g, '') == '')) { - errmsg = '{{ _('Please specify the value for label.') }}'; - this.errorModel.set('label', errmsg) - return errmsg; - } else { - this.errorModel.unset('label'); - } return null; } }); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/default/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/default/update.sql index 7f38e97..3a0a336 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/default/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/default/update.sql @@ -87,7 +87,7 @@ ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} {% if c_idx == 1 %} {# if first new element then add it after old data enum list#} ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }} - ADD VALUE {{r.label|qtLiteral}} AFTER {{o_data.enum[o_enum_len].label|qtLiteral }}; + ADD VALUE {{r.label|qtLiteral}} {% if o_enum_len > 0 %}AFTER {{o_data.enum[o_enum_len].label|qtLiteral }}{% endif %}; {% else %} {# if first new element then add it after new data enum list#} {% set p_idx = loop.index - 2 %}
-- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers