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`
| 3408 | |
| 3409 | |
| 3410 | class ColumnDefault(DefaultGenerator, ABC): |
| 3411 | """A plain default value on a column. |
| 3412 | |
| 3413 | This could correspond to a constant, a callable function, |
| 3414 | or a SQL clause. |
| 3415 | |
| 3416 | :class:`.ColumnDefault` is generated automatically |
| 3417 | whenever the ``default``, ``onupdate`` arguments of |
| 3418 | :class:`_schema.Column` are used. A :class:`.ColumnDefault` |
| 3419 | can be passed positionally as well. |
| 3420 | |
| 3421 | For example, the following:: |
| 3422 | |
| 3423 | Column("foo", Integer, default=50) |
| 3424 | |
| 3425 | Is equivalent to:: |
| 3426 | |
| 3427 | Column("foo", Integer, ColumnDefault(50)) |
| 3428 | |
| 3429 | """ |
| 3430 | |
| 3431 | arg: Any |
| 3432 | |
| 3433 | @overload |
| 3434 | def __new__( |
| 3435 | cls, arg: Callable[..., Any], for_update: bool = ... |
| 3436 | ) -> CallableColumnDefault: ... |
| 3437 | |
| 3438 | @overload |
| 3439 | def __new__( |
| 3440 | cls, arg: ColumnElement[Any], for_update: bool = ... |
| 3441 | ) -> ColumnElementColumnDefault: ... |
| 3442 | |
| 3443 | # if I return ScalarElementColumnDefault here, which is what's actually |
| 3444 | # returned, mypy complains that |
| 3445 | # overloads overlap w/ incompatible return types. |
| 3446 | @overload |
| 3447 | def __new__(cls, arg: object, for_update: bool = ...) -> ColumnDefault: ... |
| 3448 | |
| 3449 | def __new__( |
| 3450 | cls, arg: Any = None, for_update: bool = False |
| 3451 | ) -> ColumnDefault: |
| 3452 | """Construct a new :class:`.ColumnDefault`. |
| 3453 | |
| 3454 | |
| 3455 | :param arg: argument representing the default value. |
| 3456 | May be one of the following: |
| 3457 | |
| 3458 | * a plain non-callable Python value, such as a |
| 3459 | string, integer, boolean, or other simple type. |
| 3460 | The default value will be used as is each time. |
| 3461 | * a SQL expression, that is one which derives from |
| 3462 | :class:`_expression.ColumnElement`. The SQL expression will |
| 3463 | be rendered into the INSERT or UPDATE statement, |
| 3464 | or in the case of a primary key column when |
| 3465 | RETURNING is not used may be |
| 3466 | pre-executed before an INSERT within a SELECT. |
| 3467 | * A Python callable. The function will be invoked for each |
no outgoing calls