MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _column_query

Method _column_query

lib/sqlalchemy/dialects/oracle/base.py:2886–2957  ·  lib/sqlalchemy/dialects/oracle/base.py::OracleDialect._column_query
(self, owner)

Source from the content-addressed store, hash-verified

2884
2885 @lru_cache()
2886 def _column_query(self, owner):
2887 all_cols = dictionary.all_tab_cols
2888 all_comments = dictionary.all_col_comments
2889 all_ids = dictionary.all_tab_identity_cols
2890
2891 if self.server_version_info >= (12,):
2892 add_cols = (
2893 all_cols.c.default_on_null,
2894 sql.case(
2895 (all_ids.c.table_name.is_(None), sql.null()),
2896 else_=all_ids.c.generation_type
2897 + class="st">","
2898 + all_ids.c.identity_options,
2899 ).label(class="st">"identity_options"),
2900 )
2901 join_identity_cols = True
2902 else:
2903 add_cols = (
2904 sql.null().label(class="st">"default_on_null"),
2905 sql.null().label(class="st">"identity_options"),
2906 )
2907 join_identity_cols = False
2908
2909 class="cm"># NOTE: on oracle cannot create tables/views without columns and
2910 class="cm"># a table cannot have all column hidden:
2911 class="cm"># ORA-54039: table must have at least one column that is not invisible
2912 class="cm"># all_tab_cols returns data for tables/views/mat-views.
2913 class="cm"># all_tab_cols does not return recycled tables
2914
2915 query = (
2916 select(
2917 all_cols.c.table_name,
2918 all_cols.c.column_name,
2919 all_cols.c.data_type,
2920 all_cols.c.char_length,
2921 all_cols.c.data_length,
2922 all_cols.c.data_precision,
2923 all_cols.c.data_scale,
2924 all_cols.c.nullable,
2925 all_cols.c.data_default,
2926 all_comments.c.comments,
2927 all_cols.c.virtual_column,
2928 *add_cols,
2929 ).select_from(all_cols)
2930 class="cm"># NOTE: all_col_comments has a row for each column even if no
2931 class="cm"># comment is present, so a join could be performed, but there
2932 class="cm"># seems to be no difference compared to an outer join
2933 .outerjoin(
2934 all_comments,
2935 and_(
2936 all_cols.c.table_name == all_comments.c.table_name,
2937 all_cols.c.column_name == all_comments.c.column_name,
2938 all_cols.c.owner == all_comments.c.owner,
2939 ),
2940 )
2941 )
2942 if join_identity_cols:
2943 query = query.outerjoin(

Callers 2

get_multi_columnsMethod · 0.95
init_classMethod · 0.95

Calls 10

selectFunction · 0.90
and_Function · 0.85
bindparamFunction · 0.85
labelMethod · 0.45
is_Method · 0.45
outerjoinMethod · 0.45
select_fromMethod · 0.45
order_byMethod · 0.45
whereMethod · 0.45
in_Method · 0.45

Tested by

no test coverage detected