(
compiler,
stmt,
compile_state,
stmt_parameter_tuples,
check_columns,
_col_bind_name,
_getattr_col_key,
values,
kw,
)
| 1460 | |
| 1461 | |
| 1462 | def _get_update_multitable_params( |
| 1463 | compiler, |
| 1464 | stmt, |
| 1465 | compile_state, |
| 1466 | stmt_parameter_tuples, |
| 1467 | check_columns, |
| 1468 | _col_bind_name, |
| 1469 | _getattr_col_key, |
| 1470 | values, |
| 1471 | kw, |
| 1472 | ): |
| 1473 | normalized_params = { |
| 1474 | coercions.expect(roles.DMLColumnRole, c): param |
| 1475 | for c, param in stmt_parameter_tuples or () |
| 1476 | } |
| 1477 | |
| 1478 | include_table = compile_state.include_table_with_column_exprs |
| 1479 | |
| 1480 | affected_tables = set() |
| 1481 | for t in compile_state._extra_froms: |
| 1482 | # extra gymnastics to support the probably-shouldnt-have-supported |
| 1483 | # case of "UPDATE table AS alias SET table.foo = bar", but it's |
| 1484 | # supported |
| 1485 | we_shouldnt_be_here_if_columns_found = ( |
| 1486 | not include_table |
| 1487 | and not compile_state.dml_table.is_derived_from(t) |
| 1488 | ) |
| 1489 | |
| 1490 | for c in t.c: |
| 1491 | if c in normalized_params: |
| 1492 | |
| 1493 | if we_shouldnt_be_here_if_columns_found: |
| 1494 | raise exc.CompileError( |
| 1495 | "Backend does not support additional tables " |
| 1496 | "in the SET " |
| 1497 | "clause; cannot include columns from table(s) " |
| 1498 | f"'{t.description}' in " |
| 1499 | "SET clause" |
| 1500 | ) |
| 1501 | |
| 1502 | affected_tables.add(t) |
| 1503 | |
| 1504 | check_columns[_getattr_col_key(c)] = c |
| 1505 | value = normalized_params[c] |
| 1506 | |
| 1507 | col_value = compiler.process(c, include_table=include_table) |
| 1508 | if coercions._is_literal(value): |
| 1509 | value = _create_bind_param( |
| 1510 | compiler, |
| 1511 | c, |
| 1512 | value, |
| 1513 | required=value is REQUIRED, |
| 1514 | name=_col_bind_name(c), |
| 1515 | **kw, # TODO: no test coverage for literal binds here |
| 1516 | ) |
| 1517 | accumulated_bind_names: Iterable[str] = (c.key,) |
| 1518 | elif value._is_bind_parameter: |
| 1519 | cbn = _col_bind_name(c) |
no test coverage detected