Fixed an issue where Schema Diff not generating difference for missing columns. #7104

pull/7106/head
Akshay Joshi 2024-01-08 09:39:39 +05:30
parent ec5ea7e207
commit 5e710f7ee3
4 changed files with 28 additions and 30 deletions

View File

@ -46,3 +46,4 @@ Bug fixes
| `Issue #7078 <https://github.com/pgadmin-org/pgadmin4/issues/7078>`_ - Fixed an issue where user is not able to cancel or terminate active queries from dashboard.
| `Issue #7082 <https://github.com/pgadmin-org/pgadmin4/issues/7082>`_ - Fixed browser autocomplete related issues on pgAdmin authentication related pages.
| `Issue #7091 <https://github.com/pgadmin-org/pgadmin4/issues/7091>`_ - Fixed an issue where auto commit/rollback setting not persisting across query tool connection change.
| `Issue #7104 <https://github.com/pgadmin-org/pgadmin4/issues/7104>`_ - Fixed an issue where Schema Diff not generating difference for missing columns.

View File

@ -663,7 +663,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
_, exc_value, _ = sys.exc_info()
return internal_server_error(errormsg=str(exc_value))
@check_precondition
@ -702,7 +702,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status=200
)
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
_, exc_value, _ = sys.exc_info()
return internal_server_error(errormsg=str(exc_value))
@check_precondition
@ -726,8 +726,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
"""
try:
# Get SQL to create Foreign Table
SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request)
SQL, _ = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=self.request)
# Most probably this is due to error
if not isinstance(SQL, str):
return SQL
@ -904,7 +904,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
col_data = []
for c in data['columns']:
if ('inheritedfrom' not in c) or (c['inheritedfrom'] is None):
if c.get('inheritedfrom', None) is None:
col_data.append(c)
data['columns'] = col_data
@ -974,8 +974,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
except TypeError:
data[k] = v
try:
SQL, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=data, foid=foid)
SQL, _ = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=data, foid=foid)
# Most probably this is due to error
if not isinstance(SQL, str):
return SQL
@ -1189,8 +1189,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
c['schema'] = data['schema']
c['table'] = data['name']
# Sql for drop column
if 'inheritedfrom' not in c or \
('inheritedfrom' in c and c['inheritedfrom'] is None):
if c.get('inheritedfrom', None) is None:
column_sql += render_template("/".join(
[self.foreign_table_column_template_path,
self._DELETE_SQL]),
@ -1233,8 +1232,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
old_col_data['cltype'])
# Sql for alter column
if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c:
if c.get('inheritedfrom', None) is None and \
c.get('inheritedfromtable', None) is None:
column_sql += render_template("/".join(
[self.foreign_table_column_template_path,
self._UPDATE_SQL]),
@ -1251,8 +1250,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
c = column_utils.convert_length_precision_to_string(c)
if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c:
if c.get('inheritedfrom', None) is None and \
c.get('inheritedfromtable', None) is None:
column_sql += render_template("/".join(
[self.foreign_table_column_template_path,
self._CREATE_SQL]),
@ -1416,7 +1415,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
'edit_mode_types_multi.sql']),
type_ids=",".join(map(lambda x: str(x),
edit_types.keys())))
status, res = self.conn.execute_2darray(SQL)
_, res = self.conn.execute_2darray(SQL)
for row in res['rows']:
edit_types[row['main_oid']] = sorted(row['edit_types'])
@ -1759,9 +1758,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
target_schema = kwargs.get('target_schema', None)
if data:
sql, name = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=data, foid=oid,
is_schema_diff=True)
sql, _ = self.get_sql(gid=gid, sid=sid, did=did, scid=scid,
data=data, foid=oid, is_schema_diff=True)
else:
if drop_sql:
sql = self.delete(gid=gid, sid=sid, did=did,

View File

@ -336,7 +336,7 @@ def _parse_format_col_for_edit(data, columns, column_acl):
if action in columns:
final_columns = []
for c in columns[action]:
if 'inheritedfrom' not in c:
if c.get('inheritedfrom', None) is None:
final_columns.append(c)
_parse_column_actions(final_columns, column_acl)
@ -440,7 +440,7 @@ def fetch_length_precision(data):
length = False
precision = False
if 'elemoid' in data:
length, precision, typeval = \
length, precision, _ = \
DataTypeReader.get_length_precision(data['elemoid'])
# Set length and precision to None

View File

@ -1102,7 +1102,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
tid: Table ID
"""
# checking the table existence using the function of the same class
schema_name, table_name = self.get_schema_and_table_name(tid)
_, table_name = self.get_schema_and_table_name(tid)
if table_name is None:
return gone(gettext(self.not_found_error_msg()))
@ -1274,8 +1274,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
c['schema'] = data['schema']
c['table'] = data['name']
# Sql for drop column
if 'inheritedfrom' not in c or \
('inheritedfrom' in c and c['inheritedfrom'] is None):
if c.get('inheritedfrom', None) is None:
column_sql += render_template("/".join(
[self.column_template_path, self._DELETE_SQL]),
data=c, conn=self.conn).strip('\n') + \
@ -1317,8 +1316,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
old_col_data['cltype'])
# Sql for alter column
if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c:
if c.get('inheritedfrom', None) is None and \
c.get('inheritedfromtable', None) is None:
column_sql += render_template("/".join(
[self.column_template_path, self._UPDATE_SQL]),
data=c, o_data=old_col_data, conn=self.conn
@ -1334,8 +1333,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
c = column_utils.convert_length_precision_to_string(c)
if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c:
if c.get('inheritedfrom', None) is None and \
c.get('inheritedfromtable', None) is None:
column_sql += render_template("/".join(
[self.column_template_path, self._CREATE_SQL]),
data=c, conn=self.conn).strip('\n') + \
@ -1539,7 +1538,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
sql = self._check_for_constraints(index_constraint_sql, data, did,
tid, sql)
else:
error, errmsg = BaseTableView._check_for_create_sql(data)
error, _ = BaseTableView._check_for_create_sql(data)
if error:
return gettext('-- definition incomplete'), data['name']
@ -1599,7 +1598,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
parent_id = kwargs.get('parent_id', None)
# checking the table existence using the function of the same class
schema_name, table_name = self.get_schema_and_table_name(tid)
_, table_name = self.get_schema_and_table_name(tid)
if table_name is None:
return gone(gettext(self.not_found_error_msg()))
@ -2053,7 +2052,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
sql = render_template(
"/".join([self.table_template_path, 'locks.sql']), did=did
)
status, lock_table_result = self.conn.execute_dict(sql)
_, lock_table_result = self.conn.execute_dict(sql)
for row in lock_table_result['rows']:
if row['relation'].strip('\"') == data['name']:
@ -2062,7 +2061,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable, VacuumSettings):
"/".join([self.table_template_path,
'get_application_name.sql']), pid=row['pid']
)
status, res = self.conn.execute_dict(sql)
_, res = self.conn.execute_dict(sql)
application_name = res['rows'][0]['application_name']