Remove arbitrary (and incorrect) requirement that composite types must have at least two members. Fixes #4451

This commit is contained in:
Aditya Toshniwal
2019-11-01 15:21:59 +00:00
committed by Dave Page
parent a7d8b9de8c
commit 080ccdda5b
4 changed files with 38 additions and 15 deletions

View File

@@ -929,16 +929,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
)
)
# Additional checks goes here
# If type is composite then check if it has two members
if data and data[arg] == 'c':
if len(data['composite']) < 2:
return make_json_response(
status=410,
success=0,
errormsg=gettext(
'Composite types require at least two members.'
)
)
# If type is range then check if subtype is defined or not
if data and data[arg] == 'r':
if 'typname' not in data or data['typname'] is None:
@@ -1285,11 +1275,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
return "-- definition incomplete"
# Additional checks go here
# If type is composite then check if it has two members
if data and data[arg] == 'c':
if len(data['composite']) < 2:
return "-- definition incomplete"
# If type is range then check if subtype is defined or not
if data and data[arg] == 'r':
if 'typname' not in data or data['typname'] is None:

View File

@@ -0,0 +1,11 @@
-- Type: composite_type_$%{}[]()&*^!@"'`\/#
-- DROP TYPE public."composite_type_$%{}[]()&*^!@""'`\/#";
CREATE TYPE public."composite_type_$%{}[]()&*^!@""'`\/#" AS
(
mname1 bigint
);
ALTER TYPE public."composite_type_$%{}[]()&*^!@""'`\/#"
OWNER TO <OWNER>;

View File

@@ -108,6 +108,32 @@
"data": {}
},
{
"type": "create",
"name": "Create Composite type - one field",
"endpoint": "NODE-type.obj",
"sql_endpoint": "NODE-type.sql_id",
"data": {
"name": "composite_type_$%{}[]()&*^!@\"'`\\/#",
"is_sys_type":false,
"typtype":"c",
"schema":"public",
"composite":[
{"member_name":"mname1","type":"bigint","is_tlength":false,"is_precision":false}
],
"typacl":[],
"seclabels":[],
"description":""
},
"expected_sql_file": "create_composite_type_one_field.sql"
},
{
"type": "delete",
"name": "Drop Composite type - one field",
"endpoint": "NODE-type.obj_id",
"sql_endpoint": "NODE-type.sql_id",
"data": {}
},
{
"type": "create",