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

Method visit_bindparam

lib/sqlalchemy/sql/compiler.py:3692–3866  ·  view source on GitHub ↗
(
        self,
        bindparam,
        within_columns_clause=False,
        literal_binds=False,
        skip_bind_expression=False,
        literal_execute=False,
        render_postcompile=False,
        is_upsert_set=False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

3690 )
3691
3692 def visit_bindparam(
3693 self,
3694 bindparam,
3695 within_columns_clause=False,
3696 literal_binds=False,
3697 skip_bind_expression=False,
3698 literal_execute=False,
3699 render_postcompile=False,
3700 is_upsert_set=False,
3701 **kwargs,
3702 ):
3703 # Detect parametrized bindparams in upsert SET clause for issue #13130
3704 if (
3705 is_upsert_set
3706 and bindparam.value is None
3707 and bindparam.callable is None
3708 and self._insertmanyvalues is not None
3709 ):
3710 self._insertmanyvalues = self._insertmanyvalues._replace(
3711 has_upsert_bound_parameters=True
3712 )
3713
3714 if not skip_bind_expression:
3715 impl = bindparam.type.dialect_impl(self.dialect)
3716 if impl._has_bind_expression:
3717 bind_expression = impl.bind_expression(bindparam)
3718 wrapped = self.process(
3719 bind_expression,
3720 skip_bind_expression=True,
3721 within_columns_clause=within_columns_clause,
3722 literal_binds=literal_binds and not bindparam.expanding,
3723 literal_execute=literal_execute,
3724 render_postcompile=render_postcompile,
3725 **kwargs,
3726 )
3727 if bindparam.expanding:
3728 # for postcompile w/ expanding, move the "wrapped" part
3729 # of this into the inside
3730
3731 m = re.match(
3732 r"^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$", wrapped
3733 )
3734 assert m, "unexpected format for expanding parameter"
3735 wrapped = "(__[POSTCOMPILE_%s~~%s~~REPL~~%s~~])" % (
3736 m.group(2),
3737 m.group(1),
3738 m.group(3),
3739 )
3740
3741 if literal_binds:
3742 ret = self.render_literal_bindparam(
3743 bindparam,
3744 within_columns_clause=True,
3745 bind_expression_template=wrapped,
3746 **kwargs,
3747 )
3748 return "(%s)" % ret
3749

Callers

nothing calls this directly

Calls 10

_truncate_bindparamMethod · 0.95
bindparam_stringMethod · 0.95
_replaceMethod · 0.80
dialect_implMethod · 0.45
bind_expressionMethod · 0.45
processMethod · 0.45
matchMethod · 0.45
intersectionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected