MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / update_stmt

Function update_stmt

lib/sqlalchemy/orm/persistence.py:753–774  ·  view source on GitHub ↗
(existing_stmt=None)

Source from the content-addressed store, hash-verified

751 execution_options = {"compiled_cache": base_mapper._compiled_cache}
752
753 def update_stmt(existing_stmt=None):
754 clauses = BooleanClauseList._construct_raw(operators.and_)
755
756 for col in mapper._pks_by_table[table]:
757 clauses._append_inplace(
758 col == sql.bindparam(col._label, type_=col.type)
759 )
760
761 if needs_version_id:
762 clauses._append_inplace(
763 mapper.version_id_col
764 == sql.bindparam(
765 mapper.version_id_col._label,
766 type_=mapper.version_id_col.type,
767 )
768 )
769
770 if existing_stmt is not None:
771 stmt = existing_stmt.where(clauses)
772 else:
773 stmt = table.update().where(clauses)
774 return stmt
775
776 if use_orm_update_stmt is not None:
777 cached_stmt = update_stmt(use_orm_update_stmt)

Callers 1

_emit_update_statementsFunction · 0.85

Calls 4

_append_inplaceMethod · 0.80
_construct_rawMethod · 0.45
whereMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected