Allow creation of ENUM types with no members. Fixes #2426

This commit is contained in:
Murtuza Zabuawala 2017-05-26 12:21:23 -04:00 committed by Dave Page
parent dba64e77f1
commit 2c9af4784e
3 changed files with 1 additions and 23 deletions

View File

@ -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:

View File

@ -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;
}
});

View File

@ -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 %}