MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / _all_objects_query

Method _all_objects_query

lib/sqlalchemy/dialects/oracle/base.py:2423–2481  ·  view source on GitHub ↗
(
        self, owner, scope, kind, has_filter_names, has_mat_views
    )

Source from the content-addressed store, hash-verified

2421
2422 @lru_cache()
2423 def _all_objects_query(
2424 self, owner, scope, kind, has_filter_names, has_mat_views
2425 ):
2426 query = (
2427 select(dictionary.all_objects.c.object_name)
2428 .select_from(dictionary.all_objects)
2429 .where(dictionary.all_objects.c.owner == owner)
2430 )
2431
2432 # NOTE: materialized views are listed in all_objects twice;
2433 # once as MATERIALIZE VIEW and once as TABLE
2434 if kind is ObjectKind.ANY:
2435 # materilaized view are listed also as tables so there is no
2436 # need to add them to the in_.
2437 query = query.where(
2438 dictionary.all_objects.c.object_type.in_(("TABLE", "VIEW"))
2439 )
2440 else:
2441 object_type = []
2442 if ObjectKind.VIEW in kind:
2443 object_type.append("VIEW")
2444 if (
2445 ObjectKind.MATERIALIZED_VIEW in kind
2446 and ObjectKind.TABLE not in kind
2447 ):
2448 # materilaized view are listed also as tables so there is no
2449 # need to add them to the in_ if also selecting tables.
2450 object_type.append("MATERIALIZED VIEW")
2451 if ObjectKind.TABLE in kind:
2452 object_type.append("TABLE")
2453 if has_mat_views and ObjectKind.MATERIALIZED_VIEW not in kind:
2454 # materialized view are listed also as tables,
2455 # so they need to be filtered out
2456 # EXCEPT ALL / MINUS profiles as faster than using
2457 # NOT EXISTS or NOT IN with a subquery, but it's in
2458 # general faster to get the mat view names and exclude
2459 # them only when needed
2460 query = query.where(
2461 dictionary.all_objects.c.object_name.not_in(
2462 bindparam("mat_views")
2463 )
2464 )
2465 query = query.where(
2466 dictionary.all_objects.c.object_type.in_(object_type)
2467 )
2468
2469 # handles scope
2470 if scope is ObjectScope.DEFAULT:
2471 query = query.where(dictionary.all_objects.c.temporary == "N")
2472 elif scope is ObjectScope.TEMPORARY:
2473 query = query.where(dictionary.all_objects.c.temporary == "Y")
2474
2475 if has_filter_names:
2476 query = query.where(
2477 dictionary.all_objects.c.object_name.in_(
2478 bindparam("filter_names")
2479 )
2480 )

Callers 2

_get_all_objectsMethod · 0.95
init_classMethod · 0.95

Calls 7

selectFunction · 0.90
bindparamFunction · 0.85
whereMethod · 0.45
select_fromMethod · 0.45
in_Method · 0.45
appendMethod · 0.45
not_inMethod · 0.45

Tested by

no test coverage detected