MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _get_stmt_parameter_tuples_params

Function _get_stmt_parameter_tuples_params

lib/sqlalchemy/sql/crud.py:1610–1649  ·  view source on GitHub ↗
(
    compiler,
    compile_state,
    parameters,
    stmt_parameter_tuples,
    _column_as_key,
    values,
    kw,
)

Source from the content-addressed store, hash-verified

1608
1609
1610def _get_stmt_parameter_tuples_params(
1611 compiler,
1612 compile_state,
1613 parameters,
1614 stmt_parameter_tuples,
1615 _column_as_key,
1616 values,
1617 kw,
1618):
1619 for k, v in stmt_parameter_tuples:
1620 colkey = _column_as_key(k)
1621 if colkey is not None:
1622 parameters.setdefault(colkey, v)
1623 else:
1624 # a non-Column expression on the left side;
1625 # add it to values() in an "as-is" state,
1626 # coercing right side to bound param
1627
1628 # note one of the main use cases for this is array slice
1629 # updates on PostgreSQL, as the left side is also an expression.
1630
1631 col_expr = compiler.process(
1632 k, include_table=compile_state.include_table_with_column_exprs
1633 )
1634
1635 if coercions._is_literal(v):
1636 v = compiler.process(
1637 elements.BindParameter(None, v, type_=k.type), **kw
1638 )
1639 else:
1640 if v._is_bind_parameter and v.type._isnull:
1641 # either unique parameter, or other bound parameters that
1642 # were passed in directly
1643 # set type to that of the column unconditionally
1644 v = v._with_binary_element_type(k.type)
1645
1646 v = compiler.process(v.self_group(), **kw)
1647
1648 # TODO: not sure if accumulated_bind_names applies here
1649 values.append((k, col_expr, v, ()))
1650
1651
1652def _get_returning_modifiers(compiler, stmt, compile_state, toplevel):

Callers 1

_get_crud_paramsFunction · 0.85

Calls 6

_column_as_keyFunction · 0.85
setdefaultMethod · 0.45
processMethod · 0.45
self_groupMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected