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

Method cast

lib/sqlalchemy/sql/elements.py:1702–1716  ·  view source on GitHub ↗

Produce a type cast, i.e. ``CAST( AS )``. This is a shortcut to the :func:`_expression.cast` function. .. seealso:: :ref:`tutorial_casts` :func:`_expression.cast` :func:`_expression.type_coerce`

(self, type_: _TypeEngineArgument[_OPT])

Source from the content-addressed store, hash-verified

1700 return key, co
1701
1702 def cast(self, type_: _TypeEngineArgument[_OPT]) -> Cast[_OPT]:
1703 """Produce a type cast, i.e. ``CAST(<expression> AS <type>)``.
1704
1705 This is a shortcut to the :func:`_expression.cast` function.
1706
1707 .. seealso::
1708
1709 :ref:`tutorial_casts`
1710
1711 :func:`_expression.cast`
1712
1713 :func:`_expression.type_coerce`
1714
1715 """
1716 return Cast(self, type_)
1717
1718 def label(self, name: Optional[str]) -> Label[_T]:
1719 """Produce a column label, i.e. ``<columnname> AS <name>``.

Callers 15

_columns_queryMethod · 0.45
_constraint_queryMethod · 0.45
_index_queryMethod · 0.45
_comment_queryMethod · 0.45
_enum_queryMethod · 0.45
_domain_queryMethod · 0.45
get_columnsMethod · 0.45
colFunction · 0.45
check_resultsMethod · 0.45

Calls 1

CastClass · 0.85

Tested by 13

check_resultsMethod · 0.36
test_non_functionsMethod · 0.36
test_issue_9451Function · 0.36
exprMethod · 0.36
test_queryMethod · 0.36
column_expressionMethod · 0.36
bind_expressionMethod · 0.36
setup_mappersMethod · 0.36
bind_expressionMethod · 0.36
test_criterionMethod · 0.36