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

Function update_stmt

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

Source from the content-addressed store, hash-verified

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