1) Correct the reverse engineering SQL of the collation node for database server version < 10.

2) Added 'rngcollation' and 'attnum' in the ignore list of Types node and fixed an issue occurs due to SonarQube fix.
This commit is contained in:
Akshay Joshi 2020-09-14 16:12:20 +05:30
parent 5462aeab11
commit 5eb1c57320
3 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,25 @@
{% if data %}
CREATE COLLATION {{ conn|qtIdent(data.schema, data.name) }}
{# if user has provided lc_collate & lc_type #}
{% if data.lc_collate and data.lc_type %}
(LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }});
{% endif %}
{# if user has provided locale only #}
{% if data.locale %}
(LOCALE = {{ data.locale|qtLiteral }});
{% endif %}
{# if user has choosed to copy from existing collation #}
{% if data.copy_collation %}
FROM {{ data.copy_collation }};
{% endif %}
{% if data.owner %}
ALTER COLLATION {{ conn|qtIdent(data.schema, data.name) }}
OWNER TO {{ conn|qtIdent(data.owner) }};
{% endif %}
{% if data.description %}
COMMENT ON COLLATION {{ conn|qtIdent(data.schema, data.name) }}
IS {{ data.description|qtLiteral }};
{% endif %}
{% endif %}

View File

@ -1,5 +1,10 @@
{% if data %}
{% if not data.lc_collate and not data.lc_type and not data.locale and not data.copy_collation %}
CREATE COLLATION {{ conn|qtIdent(data.schema, data.name) }}
FROM pg_catalog."default";
{% else %}
CREATE COLLATION {{ conn|qtIdent(data.schema, data.name) }}
{% endif %}
{# if user has provided lc_collate & lc_type #}
{% if data.lc_collate and data.lc_type %}
(LC_COLLATE = {{ data.lc_collate|qtLiteral }}, LC_CTYPE = {{ data.lc_type|qtLiteral }});
@ -22,4 +27,4 @@ ALTER COLLATION {{ conn|qtIdent(data.schema, data.name) }}
COMMENT ON COLLATION {{ conn|qtIdent(data.schema, data.name) }}
IS {{ data.description|qtLiteral }};
{% endif %}
{% endif %}
{% endif %}

View File

@ -216,7 +216,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
})
keys_to_ignore = ['oid', 'typnamespace', 'typrelid', 'typarray', 'alias',
'schema', 'oid-2', 'type_acl']
'schema', 'oid-2', 'type_acl', 'rngcollation', 'attnum']
def check_precondition(f):
"""
@ -1337,7 +1337,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
for row in acl['rows']:
priv = parse_priv_from_db(row)
old_data[row['deftype']] = \
old_data.get(row['deftype'], []).append(priv)
(old_data.get(row['deftype'], None) or []).append(priv)
# Calling function to check and additional properties if available
old_data.update(self.additional_properties(old_data, tid))