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

Function _get_update_multitable_params

lib/sqlalchemy/sql/crud.py:1399–1498  ·  view source on GitHub ↗
(
    compiler,
    stmt,
    compile_state,
    stmt_parameter_tuples,
    check_columns,
    _col_bind_name,
    _getattr_col_key,
    values,
    kw,
)

Source from the content-addressed store, hash-verified

1397
1398
1399def _get_update_multitable_params(
1400 compiler,
1401 stmt,
1402 compile_state,
1403 stmt_parameter_tuples,
1404 check_columns,
1405 _col_bind_name,
1406 _getattr_col_key,
1407 values,
1408 kw,
1409):
1410 normalized_params = {
1411 coercions.expect(roles.DMLColumnRole, c): param
1412 for c, param in stmt_parameter_tuples or ()
1413 }
1414
1415 include_table = compile_state.include_table_with_column_exprs
1416
1417 affected_tables = set()
1418 for t in compile_state._extra_froms:
1419 # extra gymnastics to support the probably-shouldnt-have-supported
1420 # case of "UPDATE table AS alias SET table.foo = bar", but it's
1421 # supported
1422 we_shouldnt_be_here_if_columns_found = (
1423 not include_table
1424 and not compile_state.dml_table.is_derived_from(t)
1425 )
1426
1427 for c in t.c:
1428 if c in normalized_params:
1429
1430 if we_shouldnt_be_here_if_columns_found:
1431 raise exc.CompileError(
1432 "Backend does not support additional tables "
1433 "in the SET "
1434 "clause; cannot include columns from table(s) "
1435 f"'{t.description}' in "
1436 "SET clause"
1437 )
1438
1439 affected_tables.add(t)
1440
1441 check_columns[_getattr_col_key(c)] = c
1442 value = normalized_params[c]
1443
1444 col_value = compiler.process(c, include_table=include_table)
1445 if coercions._is_literal(value):
1446 value = _create_bind_param(
1447 compiler,
1448 c,
1449 value,
1450 required=value is REQUIRED,
1451 name=_col_bind_name(c),
1452 **kw, # TODO: no test coverage for literal binds here
1453 )
1454 accumulated_bind_names: Iterable[str] = (c.key,)
1455 elif value._is_bind_parameter:
1456 cbn = _col_bind_name(c)

Callers 1

_get_crud_paramsFunction · 0.85

Calls 10

_getattr_col_keyFunction · 0.85
_create_bind_paramFunction · 0.85
_col_bind_nameFunction · 0.85
is_derived_fromMethod · 0.45
addMethod · 0.45
processMethod · 0.45
appendMethod · 0.45
self_groupMethod · 0.45

Tested by

no test coverage detected