MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _comment_query

Method _comment_query

lib/sqlalchemy/dialects/oracle/base.py:3131–3184  ·  lib/sqlalchemy/dialects/oracle/base.py::OracleDialect._comment_query
(self, owner, scope, kind, has_filter_names)

Source from the content-addressed store, hash-verified

3129
3130 @lru_cache()
3131 def _comment_query(self, owner, scope, kind, has_filter_names):
3132 class="cm"># NOTE: all_tab_comments / all_mview_comments have a row for all
3133 class="cm"># object even if they don't have comments
3134 queries = []
3135 if ObjectKind.TABLE in kind or ObjectKind.VIEW in kind:
3136 class="cm"># all_tab_comments returns also plain views
3137 tbl_view = select(
3138 dictionary.all_tab_comments.c.table_name,
3139 dictionary.all_tab_comments.c.comments,
3140 ).where(
3141 dictionary.all_tab_comments.c.owner == owner,
3142 dictionary.all_tab_comments.c.table_name.not_like(class="st">"BIN$%"),
3143 )
3144 if ObjectKind.VIEW not in kind:
3145 tbl_view = tbl_view.where(
3146 dictionary.all_tab_comments.c.table_type == class="st">"TABLE"
3147 )
3148 elif ObjectKind.TABLE not in kind:
3149 tbl_view = tbl_view.where(
3150 dictionary.all_tab_comments.c.table_type == class="st">"VIEW"
3151 )
3152 queries.append(tbl_view)
3153 if ObjectKind.MATERIALIZED_VIEW in kind:
3154 mat_view = select(
3155 dictionary.all_mview_comments.c.mview_name.label(class="st">"table_name"),
3156 dictionary.all_mview_comments.c.comments,
3157 ).where(
3158 dictionary.all_mview_comments.c.owner == owner,
3159 dictionary.all_mview_comments.c.mview_name.not_like(class="st">"BIN$%"),
3160 )
3161 queries.append(mat_view)
3162 if len(queries) == 1:
3163 query = queries[0]
3164 else:
3165 union = sql.union_all(*queries).subquery(class="st">"tables_and_views")
3166 query = select(union.c.table_name, union.c.comments)
3167
3168 name_col = query.selected_columns.table_name
3169
3170 if scope in (ObjectScope.DEFAULT, ObjectScope.TEMPORARY):
3171 temp = class="st">"Y" if scope is ObjectScope.TEMPORARY else class="st">"N"
3172 class="cm"># need distinct since materialized view are listed also
3173 class="cm"># as tables in all_objects
3174 query = query.distinct().join(
3175 dictionary.all_objects,
3176 and_(
3177 dictionary.all_objects.c.owner == owner,
3178 dictionary.all_objects.c.object_name == name_col,
3179 dictionary.all_objects.c.temporary == temp,
3180 ),
3181 )
3182 if has_filter_names:
3183 query = query.where(name_col.in_(bindparam(class="st">"filter_names")))
3184 return query
3185
3186 @_handle_synonyms_decorator
3187 def get_multi_table_comment(

Callers 2

init_classMethod · 0.95

Calls 12

selectFunction · 0.90
and_Function · 0.85
bindparamFunction · 0.85
whereMethod · 0.45
not_likeMethod · 0.45
appendMethod · 0.45
labelMethod · 0.45
subqueryMethod · 0.45
union_allMethod · 0.45
joinMethod · 0.45
distinctMethod · 0.45
in_Method · 0.45

Tested by

no test coverage detected