Include inherited column comments and defaults in reverse engineered table SQL. Fixes #2627

Include comment SQL for inherited columns in reverse engineered table SQL. Fixes #4037
Include inherited columns in SELECT scripts. Fixes #4058
pull/22/head
Aditya Toshniwal 2019-03-28 08:36:41 -04:00 committed by Dave Page
parent fbc6aea497
commit 8aaacdf96e
5 changed files with 23 additions and 26 deletions

View File

@ -38,15 +38,18 @@ Bug fixes
*********
| `Bug #1269 <https://redmine.postgresql.org/issues/1269>`_ - Fix naming inconsistency for the column and FTS parser modules.
| `Bug #2627 <https://redmine.postgresql.org/issues/2627>`_ - Include inherited column comments and defaults in reverse engineered table SQL.
| `Bug #3104 <https://redmine.postgresql.org/issues/3104>`_ - Improve a couple of German translations.
| `Bug #3887 <https://redmine.postgresql.org/issues/3887>`_ - Use the user's full email address (not just the username part) as the basis for the storage directory name.
| `Bug #3968 <https://redmine.postgresql.org/issues/3968>`_ - Update wcDocker to fix the issue where the Scratch Pad grows in size if the results panel is resized.
| `Bug #3995 <https://redmine.postgresql.org/issues/3995>`_ - Avoid 'bogus varno' message from Postgres when viewing the SQL for a table with triggers.
| `Bug #4019 <https://redmine.postgresql.org/issues/4019>`_ - Update all Python and JavaScript dependencies.
| `Bug #4037 <https://redmine.postgresql.org/issues/4037>`_ - Include comment SQL for inherited columns in reverse engineered table SQL.
| `Bug #4050 <https://redmine.postgresql.org/issues/4050>`_ - Make the WHEN field a CodeMirror control on the Event Trigger dialogue.
| `Bug #4052 <https://redmine.postgresql.org/issues/4052>`_ - Fix the online help button on the resource group dialogue.
| `Bug #4053 <https://redmine.postgresql.org/issues/4053>`_ - Enable the online help button on the index dialogue.
| `Bug #4054 <https://redmine.postgresql.org/issues/4054>`_ - Handle resultsets with zero columns correctly in the Query Tool.
| `Bug #4058 <https://redmine.postgresql.org/issues/4058>`_ - Include inherited columns in SELECT scripts.
| `Bug #4060 <https://redmine.postgresql.org/issues/4060>`_ - Fix the latexpdf doc build.
| `Bug #4062 <https://redmine.postgresql.org/issues/4062>`_ - Fix handling of numeric arrays in View/Edit Data.
| `Bug #4063 <https://redmine.postgresql.org/issues/4063>`_ - Enlarge the grab handles for resizing dialogs etc.

View File

@ -53,6 +53,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
array_to_string(tst.reloptions, ',') AS toast_table_vacuum_settings_str,
rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype,
CASE WHEN typ.typname IS NOT NULL THEN (select quote_ident(nspname) FROM pg_namespace WHERE oid = {{scid}}::oid )||'.'||quote_ident(typ.typname) ELSE typ.typname END AS typname,
typ.typrelid AS typoid,
(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
-- Added for pgAdmin4
(CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom,

View File

@ -52,6 +52,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
array_to_string(tst.reloptions, ',') AS toast_table_vacuum_settings_str,
rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype,
CASE WHEN typ.typname IS NOT NULL THEN (select quote_ident(nspname) FROM pg_namespace WHERE oid = {{scid}}::oid )||'.'||quote_ident(typ.typname) ELSE typ.typname END AS typname,
typ.typrelid AS typoid,
(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
-- Added for pgAdmin4
(CASE WHEN (substring(array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::boolean THEN true ELSE false END) AS autovacuum_custom,

View File

@ -41,8 +41,8 @@ CREATE {% if data.relpersistence %}UNLOGGED {% endif %}TABLE {{conn|qtIdent(data
{### Add columns ###}
{% if data.columns and data.columns|length > 0 %}
{% for c in data.columns %}
{% if c.name and c.cltype and not c.inheritedfrom %}
{{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval}}{% endif %}
{% if c.name and c.cltype %}
{% if c.inheritedfromtable %}-- Inherited from table {{c.inheritedfromtable}}:{% elif c.inheritedfromtype %}-- Inherited from type {{c.inheritedfromtype}}:{% endif %} {{conn|qtIdent(c.name)}} {% if is_sql %}{{c.displaytypname}}{% else %}{{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype, c.attlen, c.attprecision, c.hasSqrBracket) }}{% endif %}{% if c.collspcname %} COLLATE {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if c.defval %} DEFAULT {{c.defval}}{% endif %}
{% if not loop.last %},
{% endif %}
{% endif %}

View File

@ -609,20 +609,21 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
# 4) Find all the columns for tables and filter out columns which are
# not inherited from any table & format them one by one
other_columns = []
table_or_type = ''
# Get of_type table columns and add it into columns dict
if data['typname']:
if data['typoid']:
SQL = render_template("/".join([self.table_template_path,
'get_columns_for_table.sql']),
tname=data['typname'])
tid=data['typoid'])
status, res = self.conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
data['columns'] = res['rows']
other_columns = res['rows']
table_or_type = 'type'
# Get inherited table(s) columns and add it into columns dict
elif data['coll_inherits'] and len(data['coll_inherits']) > 0:
columns = []
# Return all tables which can be inherited & do not show
# system columns
SQL = render_template("/".join([self.table_template_path,
@ -645,8 +646,9 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
status, res = self.conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
columns.extend(res['rows'][:])
data['columns'] = columns
other_columns.extend(res['rows'][:])
table_or_type = 'table'
# We will fetch all the columns for the table using
# columns properties.sql, so we need to set template path
@ -661,24 +663,14 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
return internal_server_error(errormsg=res)
all_columns = res['rows']
# Filter inherited columns from all columns
if 'columns' in data and len(data['columns']) > 0 \
and len(all_columns) > 0:
for row in data['columns']:
for i, col in enumerate(all_columns):
# If both name are same then remove it
# as it is inherited from other table
if col['name'] == row['name']:
# Remove same column from all_columns as
# already have it columns collection
del all_columns[i]
# Add inheritedfrom details from other columns - type, table
for col in all_columns:
for other_col in other_columns:
if col['name'] == other_col['name']:
col['inheritedfrom' + table_or_type] = \
other_col['inheritedfrom']
# If any column is added then update columns collection
if len(all_columns) > 0:
data['columns'] += all_columns
# If no inherited columns found then add all columns
elif len(all_columns) > 0:
data['columns'] = all_columns
data['columns'] = all_columns
if 'columns' in data and len(data['columns']) > 0:
data = self._columns_formatter(tid, data)