MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_update

Method visit_update

lib/sqlalchemy/sql/compiler.py:6563–6711  ·  view source on GitHub ↗
(
        self,
        update_stmt: Update,
        visiting_cte: Optional[CTE] = None,
        **kw: Any,
    )

Source from the content-addressed store, hash-verified

6561 return None
6562
6563 def visit_update(
6564 self,
6565 update_stmt: Update,
6566 visiting_cte: Optional[CTE] = None,
6567 **kw: Any,
6568 ) -> str:
6569 compile_state = update_stmt._compile_state_factory(
6570 update_stmt, self, **kw
6571 )
6572 if TYPE_CHECKING:
6573 assert isinstance(compile_state, UpdateDMLState)
6574 update_stmt = compile_state.statement # type: ignore[assignment]
6575
6576 if visiting_cte is not None:
6577 kw["visiting_cte"] = visiting_cte
6578 toplevel = False
6579 else:
6580 toplevel = not self.stack
6581
6582 if toplevel:
6583 self.isupdate = True
6584 if not self.dml_compile_state:
6585 self.dml_compile_state = compile_state
6586 if not self.compile_state:
6587 self.compile_state = compile_state
6588
6589 if self.linting & COLLECT_CARTESIAN_PRODUCTS:
6590 from_linter = FromLinter({}, set())
6591 warn_linting = self.linting & WARN_LINTING
6592 if toplevel:
6593 self.from_linter = from_linter
6594 else:
6595 from_linter = None
6596 warn_linting = False
6597
6598 extra_froms = compile_state._extra_froms
6599 is_multitable = bool(extra_froms)
6600
6601 if is_multitable:
6602 # main table might be a JOIN
6603 main_froms = set(_from_objects(update_stmt.table))
6604 render_extra_froms = [
6605 f for f in extra_froms if f not in main_froms
6606 ]
6607 correlate_froms = main_froms.union(extra_froms)
6608 else:
6609 render_extra_froms = []
6610 correlate_froms = {update_stmt.table}
6611
6612 self.stack.append(
6613 {
6614 "correlate_froms": correlate_froms,
6615 "asfrom_froms": correlate_froms,
6616 "selectable": update_stmt,
6617 }
6618 )
6619
6620 text = "UPDATE "

Callers

nothing calls this directly

Calls 15

_generate_prefixesMethod · 0.95
update_tables_clauseMethod · 0.95
_setup_crud_hintsMethod · 0.95
returning_clauseMethod · 0.95
update_from_clauseMethod · 0.95
_render_cte_clauseMethod · 0.95
warnMethod · 0.95
FromLinterClass · 0.85
_from_objectsFunction · 0.85

Tested by

no test coverage detected