Added exception handling for SQLAlchemy function to check the table exists or not.

This commit is contained in:
Nikhil Mohite 2021-07-19 14:01:45 +05:30 committed by Akshay Joshi
parent b0727cc532
commit 5768ade198
2 changed files with 10 additions and 6 deletions

View File

@ -21,8 +21,8 @@ class SetSessionExpirationTimeTestCase(BaseTestGenerator):
scenarios = [
(
'TestCase for verifying session expire time is set to {0} days for '
'desktop mode'.format(SESSION_EXP_TIME_DESKTOP),
'TestCase for verifying session expire time is set to {0} days '
'for desktop mode'.format(SESSION_EXP_TIME_DESKTOP),
dict(
session_expiration_time=SESSION_EXP_TIME_DESKTOP,
is_desktop_mode=True

View File

@ -7,7 +7,6 @@
#
##########################################################################
from pgadmin.model import Version
from pgadmin.model import db
@ -22,9 +21,14 @@ def check_db_tables():
db_table_names = get_db_table_names()
# check table is actually present in the db.
for table_name in db_table_names:
if not db.engine.dialect.has_table(db.engine, table_name):
invalid_tb_names.append(table_name)
is_error = True
try:
if not db.inspect(db.engine).has_table(table_name=table_name):
invalid_tb_names.append(table_name)
is_error = True
except AttributeError:
if not db.engine.dialect.has_table(db.engine, table_name):
invalid_tb_names.append(table_name)
is_error = True
if is_error:
return True, invalid_tb_names