MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _column_query

Method _column_query

lib/sqlalchemy/dialects/oracle/base.py:2746–2817  ·  view source on GitHub ↗
(self, owner)

Source from the content-addressed store, hash-verified

2744
2745 @lru_cache()
2746 def _column_query(self, owner):
2747 all_cols = dictionary.all_tab_cols
2748 all_comments = dictionary.all_col_comments
2749 all_ids = dictionary.all_tab_identity_cols
2750
2751 if self.server_version_info >= (12,):
2752 add_cols = (
2753 all_cols.c.default_on_null,
2754 sql.case(
2755 (all_ids.c.table_name.is_(None), sql.null()),
2756 else_=all_ids.c.generation_type
2757 + ","
2758 + all_ids.c.identity_options,
2759 ).label("identity_options"),
2760 )
2761 join_identity_cols = True
2762 else:
2763 add_cols = (
2764 sql.null().label("default_on_null"),
2765 sql.null().label("identity_options"),
2766 )
2767 join_identity_cols = False
2768
2769 # NOTE: on oracle cannot create tables/views without columns and
2770 # a table cannot have all column hidden:
2771 # ORA-54039: table must have at least one column that is not invisible
2772 # all_tab_cols returns data for tables/views/mat-views.
2773 # all_tab_cols does not return recycled tables
2774
2775 query = (
2776 select(
2777 all_cols.c.table_name,
2778 all_cols.c.column_name,
2779 all_cols.c.data_type,
2780 all_cols.c.char_length,
2781 all_cols.c.data_length,
2782 all_cols.c.data_precision,
2783 all_cols.c.data_scale,
2784 all_cols.c.nullable,
2785 all_cols.c.data_default,
2786 all_comments.c.comments,
2787 all_cols.c.virtual_column,
2788 *add_cols,
2789 ).select_from(all_cols)
2790 # NOTE: all_col_comments has a row for each column even if no
2791 # comment is present, so a join could be performed, but there
2792 # seems to be no difference compared to an outer join
2793 .outerjoin(
2794 all_comments,
2795 and_(
2796 all_cols.c.table_name == all_comments.c.table_name,
2797 all_cols.c.column_name == all_comments.c.column_name,
2798 all_cols.c.owner == all_comments.c.owner,
2799 ),
2800 )
2801 )
2802 if join_identity_cols:
2803 query = query.outerjoin(

Callers 1

get_multi_columnsMethod · 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