MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / ColumnDefault

Class ColumnDefault

lib/sqlalchemy/sql/schema.py:3717–3801  ·  view source on GitHub ↗

A plain default value on a column. This could correspond to a constant, a callable function, or a SQL clause. :class:`.ColumnDefault` is generated automatically whenever the ``default``, ``onupdate`` arguments of :class:`_schema.Column` are used. A :class:`.ColumnDefault`

Source from the content-addressed store, hash-verified

3715
3716
3717class ColumnDefault(DefaultGenerator, ABC):
3718 """A plain default value on a column.
3719
3720 This could correspond to a constant, a callable function,
3721 or a SQL clause.
3722
3723 :class:`.ColumnDefault` is generated automatically
3724 whenever the ``default``, ``onupdate`` arguments of
3725 :class:`_schema.Column` are used. A :class:`.ColumnDefault`
3726 can be passed positionally as well.
3727
3728 For example, the following::
3729
3730 Column("foo", Integer, default=50)
3731
3732 Is equivalent to::
3733
3734 Column("foo", Integer, ColumnDefault(50))
3735
3736 """
3737
3738 arg: Any
3739
3740 _is_monotonic_fn = False
3741
3742 @overload
3743 def __new__(
3744 cls, arg: Callable[..., Any], for_update: bool = ...
3745 ) -> CallableColumnDefault: ...
3746
3747 @overload
3748 def __new__(
3749 cls, arg: ColumnElement[Any], for_update: bool = ...
3750 ) -> ColumnElementColumnDefault: ...
3751
3752 # if I return ScalarElementColumnDefault here, which is what's actually
3753 # returned, mypy complains that
3754 # overloads overlap w/ incompatible return types.
3755 @overload
3756 def __new__(cls, arg: object, for_update: bool = ...) -> ColumnDefault: ...
3757
3758 def __new__(
3759 cls, arg: Any = None, for_update: bool = False
3760 ) -> ColumnDefault:
3761 """Construct a new :class:`.ColumnDefault`.
3762
3763
3764 :param arg: argument representing the default value.
3765 May be one of the following:
3766
3767 * a plain non-callable Python value, such as a
3768 string, integer, boolean, or other simple type.
3769 The default value will be used as is each time.
3770 * a SQL expression, that is one which derives from
3771 :class:`_expression.ColumnElement`. The SQL expression will
3772 be rendered into the INSERT or UPDATE statement,
3773 or in the case of a primary key column when
3774 RETURNING is not used may be

Callers 4

test_assorted_reprMethod · 0.90
__init__Method · 0.85

Calls

no outgoing calls