MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / get_dependencies

Method get_dependencies

web/pgadmin/browser/utils.py:464–522  ·  view source on GitHub ↗

This function is used to fetch the dependencies for the selected node. Args: conn: Connection object object_id: Object Id of the selected node. where: where clause for the sql query (optional) show_system_objects: System object status

(self, conn, object_id, where=None,
                         show_system_objects=None, is_schema_diff=False)

Source from the content-addressed store, hash-verified

462 )
463
464 def get_dependencies(self, conn, object_id, where=None,
465 show_system_objects=None, is_schema_diff=False):
466 """
467 This function is used to fetch the dependencies for the selected node.
468
469 Args:
470 conn: Connection object
471 object_id: Object Id of the selected node.
472 where: where clause for the sql query (optional)
473 show_system_objects: System object status
474 is_schema_diff: True when function gets called from schema diff.
475
476 Returns: Dictionary of dependencies for the selected node.
477 """
478
479 # Set the sql_path
480 sql_path = 'depends/{0}/#{1}#'.format(
481 conn.manager.server_type, conn.manager.version)
482
483 if where is None:
484 where_clause = "WHERE dep.objid={0}::oid".format(object_id)
485 else:
486 where_clause = where
487
488 query = render_template("/".join([sql_path, 'dependencies.sql']),
489 where_clause=where_clause,
490 object_id=object_id)
491 # fetch the dependency for the selected object
492 dependencies = self.__fetch_dependency(
493 conn, query, show_system_objects, is_schema_diff)
494
495 # fetch role dependencies
496 if where_clause.find('subid') < 0:
497 sql = render_template(
498 "/".join([sql_path, 'role_dependencies.sql']),
499 where_clause=where_clause, conn=conn)
500
501 status, result = conn.execute_dict(sql)
502 if not status:
503 current_app.logger.error(result)
504
505 for row in result['rows']:
506 ref_name = row['refname']
507 dep_str = row['deptype']
508 dep_type = ''
509
510 if dep_str == 'a':
511 dep_type = 'ACL'
512 elif dep_str == 'o':
513 dep_type = 'Owner'
514
515 if row['refclassid'] == 1260:
516 dependencies.append(
517 {'type': 'role',
518 'name': ref_name,
519 'field': dep_type}
520 )
521

Callers 2

_get_source_listFunction · 0.45

Calls 6

__fetch_dependencyMethod · 0.95
joinMethod · 0.80
findMethod · 0.80
errorMethod · 0.80
appendMethod · 0.80
execute_dictMethod · 0.45

Tested by

no test coverage detected