MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / visit_bindparam

Method visit_bindparam

lib/sqlalchemy/sql/compiler.py:3871–4045  ·  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

3869 return f"__BINDMARKER_~~{element.column.key}~~"
3870
3871 def visit_bindparam(
3872 self,
3873 bindparam,
3874 within_columns_clause=False,
3875 literal_binds=False,
3876 skip_bind_expression=False,
3877 literal_execute=False,
3878 render_postcompile=False,
3879 is_upsert_set=False,
3880 **kwargs,
3881 ):
3882 # Detect parametrized bindparams in upsert SET clause for issue #13130
3883 if (
3884 is_upsert_set
3885 and bindparam.value is None
3886 and bindparam.callable is None
3887 and self._insertmanyvalues is not None
3888 ):
3889 self._insertmanyvalues = self._insertmanyvalues._replace(
3890 has_upsert_bound_parameters=True
3891 )
3892
3893 if not skip_bind_expression:
3894 impl = bindparam.type.dialect_impl(self.dialect)
3895 if impl._has_bind_expression:
3896 bind_expression = impl.bind_expression(bindparam)
3897 wrapped = self.process(
3898 bind_expression,
3899 skip_bind_expression=True,
3900 within_columns_clause=within_columns_clause,
3901 literal_binds=literal_binds and not bindparam.expanding,
3902 literal_execute=literal_execute,
3903 render_postcompile=render_postcompile,
3904 **kwargs,
3905 )
3906 if bindparam.expanding:
3907 # for postcompile w/ expanding, move the "wrapped" part
3908 # of this into the inside
3909
3910 m = re.match(
3911 r"^(.*)\(__\[POSTCOMPILE_(\S+?)\]\)(.*)$", wrapped
3912 )
3913 assert m, "unexpected format for expanding parameter"
3914 wrapped = "(__[POSTCOMPILE_%s~~%s~~REPL~~%s~~])" % (
3915 m.group(2),
3916 m.group(1),
3917 m.group(3),
3918 )
3919
3920 if literal_binds:
3921 ret = self.render_literal_bindparam(
3922 bindparam,
3923 within_columns_clause=True,
3924 bind_expression_template=wrapped,
3925 **kwargs,
3926 )
3927 return f"({ret})"
3928

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