Fixed an issue where fetching the schema throws an error if the database

is not connected in Schema Diff. Fixes #5673

Maintenance Database is selected by default in Schema Diff.
This commit is contained in:
Akshay Joshi 2020-07-15 13:07:28 +05:30
parent bd9dc97b4f
commit 2469032f15
3 changed files with 21 additions and 14 deletions

View File

@ -39,4 +39,5 @@ Bug fixes
| `Issue #5630 <https://redmine.postgresql.org/issues/5630>`_ - Fixed an issue where installation of pgadmin4 not working on 32-bit Windows.
| `Issue #5631 <https://redmine.postgresql.org/issues/5631>`_ - Fixed 'cant execute empty query' issue when remove the value of 'USING' or 'WITH CHECK' option of RLS Policy.
| `Issue #5633 <https://redmine.postgresql.org/issues/5633>`_ - Ensure that create RLS Policy menu should not be visible for catalog objects.
| `Issue #5662 <https://redmine.postgresql.org/issues/5662>`_ - Fixed accessibility issue where few dialogs are not rendering properly when we zoomed in browser window 200% and screen resolution is low.
| `Issue #5662 <https://redmine.postgresql.org/issues/5662>`_ - Fixed accessibility issue where few dialogs are not rendering properly when we zoomed in browser window 200% and screen resolution is low.
| `Issue #5673 <https://redmine.postgresql.org/issues/5673>`_ - Fixed an issue where fetching the schema throws an error if the database is not connected in Schema Diff.

View File

@ -387,7 +387,8 @@ def databases(sid):
"connected": db['connected'],
"allowConn": db['allowConn'],
"image": db['icon'],
"canDisconn": db['canDisconn']
"canDisconn": db['canDisconn'],
"is_maintenance_db": db['label'] == server.maintenance_db
})
except Exception as e:
@ -412,14 +413,15 @@ def schemas(sid, did):
view = SchemaDiffRegistry.get_node_view('schema')
server = Server.query.filter_by(id=sid).first()
response = view.nodes(gid=server.servergroup_id, sid=sid, did=did)
schemas = json.loads(response.data)['data']
for sch in schemas:
res.append({
"value": sch['_id'],
"label": sch['label'],
"_id": sch['_id'],
"image": sch['icon'],
})
if response.status_code == 200:
schemas = json.loads(response.data)['data']
for sch in schemas:
res.append({
"value": sch['_id'],
"label": sch['label'],
"_id": sch['_id'],
"image": sch['icon'],
})
except Exception as e:
app.logger.exception(e)

View File

@ -590,8 +590,10 @@ export default class SchemaDiffUI {
if (!_.isUndefined(m.get('source_sid')) && !_.isNull(m.get('source_sid'))
&& m.get('source_sid') !== '') {
setTimeout(function() {
if (self_local.options.length > 0) {
m.set('source_did', self_local.options[0].value);
for (var i = 0; i < self_local.options.length; i++) {
if (self_local.options[i].is_maintenance_db) {
m.set('source_did', self_local.options[i].value);
}
}
}, 10);
return false;
@ -679,8 +681,10 @@ export default class SchemaDiffUI {
if (!_.isUndefined(m.get('target_sid')) && !_.isNull(m.get('target_sid'))
&& m.get('target_sid') !== '') {
setTimeout(function() {
if (self.options.length > 0) {
m.set('target_did', self.options[0].value);
for (var i = 0; i < self.options.length; i++) {
if (self.options[i].is_maintenance_db) {
m.set('target_did', self.options[i].value);
}
}
}, 10);
return false;