r"""A placeholder that may be used in compiled INSERT or UPDATE expressions to refer to the SQL expression or value being applied to another column. Given a table such as:: t = Table( "t", MetaData(), Column("x", Integer), Column("y",
(column: _OnlyColumnArgument[_T])
| 490 | |
| 491 | |
| 492 | def from_dml_column(column: _OnlyColumnArgument[_T]) -> DMLTargetCopy[_T]: |
| 493 | r"""A placeholder that may be used in compiled INSERT or UPDATE expressions |
| 494 | to refer to the SQL expression or value being applied to another column. |
| 495 | |
| 496 | Given a table such as:: |
| 497 | |
| 498 | t = Table( |
| 499 | "t", |
| 500 | MetaData(), |
| 501 | Column("x", Integer), |
| 502 | Column("y", Integer), |
| 503 | ) |
| 504 | |
| 505 | The :func:`_sql.from_dml_column` construct allows automatic copying |
| 506 | of an expression assigned to a different column to be reused:: |
| 507 | |
| 508 | >>> stmt = t.insert().values(x=func.foobar(3), y=from_dml_column(t.c.x) + 5) |
| 509 | >>> print(stmt) |
| 510 | INSERT INTO t (x, y) VALUES (foobar(:foobar_1), (foobar(:foobar_1) + :param_1)) |
| 511 | |
| 512 | The :func:`_sql.from_dml_column` construct is intended to be useful primarily |
| 513 | with event-based hooks such as those used by ORM hybrids. |
| 514 | |
| 515 | .. seealso:: |
| 516 | |
| 517 | :ref:`hybrid_bulk_update` |
| 518 | |
| 519 | .. versionadded:: 2.1 |
| 520 | |
| 521 | |
| 522 | """ # noqa: E501 |
| 523 | |
| 524 | return DMLTargetCopy(column) |
| 525 | |
| 526 | |
| 527 | def bindparam( |