MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _reflect_column

Method _reflect_column

lib/sqlalchemy/engine/reflection.py:1628–1698  ·  view source on GitHub ↗
(
        self,
        table: sa_schema.Table,
        col_d: ReflectedColumn,
        include_columns: Optional[Collection[str]],
        exclude_columns: Collection[str],
        cols_by_orig_name: Dict[str, sa_schema.Column[Any]],
    )

Source from the content-addressed store, hash-verified

1626 )
1627
1628 def _reflect_column(
1629 self,
1630 table: sa_schema.Table,
1631 col_d: ReflectedColumn,
1632 include_columns: Optional[Collection[str]],
1633 exclude_columns: Collection[str],
1634 cols_by_orig_name: Dict[str, sa_schema.Column[Any]],
1635 ) -> None:
1636 orig_name = col_d["name"]
1637
1638 table.metadata.dispatch.column_reflect(self, table, col_d)
1639 table.dispatch.column_reflect(self, table, col_d)
1640
1641 # fetch name again as column_reflect is allowed to
1642 # change it
1643 name = col_d["name"]
1644 if (include_columns and name not in include_columns) or (
1645 exclude_columns and name in exclude_columns
1646 ):
1647 return
1648
1649 coltype = col_d["type"]
1650
1651 col_kw = {
1652 k: col_d[k] # type: ignore[literal-required]
1653 for k in [
1654 "nullable",
1655 "autoincrement",
1656 "quote",
1657 "info",
1658 "key",
1659 "comment",
1660 ]
1661 if k in col_d
1662 }
1663
1664 if "dialect_options" in col_d:
1665 col_kw.update(col_d["dialect_options"])
1666
1667 colargs = []
1668 default: Any
1669 if col_d.get("default") is not None:
1670 default_text = col_d["default"]
1671 assert default_text is not None
1672 if isinstance(default_text, TextClause):
1673 default = sa_schema.DefaultClause(
1674 default_text, _reflected=True
1675 )
1676 elif not isinstance(default_text, sa_schema.FetchedValue):
1677 default = sa_schema.DefaultClause(
1678 sql.text(default_text), _reflected=True
1679 )
1680 else:
1681 default = default_text
1682 colargs.append(default)
1683
1684 if "computed" in col_d:
1685 computed = sa_schema.Computed(**col_d["computed"])

Callers 1

reflect_tableMethod · 0.95

Calls 5

column_reflectMethod · 0.45
updateMethod · 0.45
getMethod · 0.45
appendMethod · 0.45
append_columnMethod · 0.45

Tested by

no test coverage detected