(
self,
name: str,
post_compile: bool = False,
expanding: bool = False,
escaped_from: Optional[str] = None,
bindparam_type: Optional[TypeEngine[Any]] = None,
accumulate_bind_names: Optional[Set[str]] = None,
visited_bindparam: Optional[List[str]] = None,
**kw: Any,
)
| 3978 | return name % self.anon_map |
| 3979 | |
| 3980 | def bindparam_string( |
| 3981 | self, |
| 3982 | name: str, |
| 3983 | post_compile: bool = False, |
| 3984 | expanding: bool = False, |
| 3985 | escaped_from: Optional[str] = None, |
| 3986 | bindparam_type: Optional[TypeEngine[Any]] = None, |
| 3987 | accumulate_bind_names: Optional[Set[str]] = None, |
| 3988 | visited_bindparam: Optional[List[str]] = None, |
| 3989 | **kw: Any, |
| 3990 | ) -> str: |
| 3991 | # TODO: accumulate_bind_names is passed by crud.py to gather |
| 3992 | # names on a per-value basis, visited_bindparam is passed by |
| 3993 | # visit_insert() to collect all parameters in the statement. |
| 3994 | # see if this gathering can be simplified somehow |
| 3995 | if accumulate_bind_names is not None: |
| 3996 | accumulate_bind_names.add(name) |
| 3997 | if visited_bindparam is not None: |
| 3998 | visited_bindparam.append(name) |
| 3999 | |
| 4000 | if not escaped_from: |
| 4001 | if self._bind_translate_re.search(name): |
| 4002 | # not quite the translate use case as we want to |
| 4003 | # also get a quick boolean if we even found |
| 4004 | # unusual characters in the name |
| 4005 | new_name = self._bind_translate_re.sub( |
| 4006 | lambda m: self._bind_translate_chars[m.group(0)], |
| 4007 | name, |
| 4008 | ) |
| 4009 | escaped_from = name |
| 4010 | name = new_name |
| 4011 | |
| 4012 | if escaped_from: |
| 4013 | self.escaped_bind_names = self.escaped_bind_names.union( |
| 4014 | {escaped_from: name} |
| 4015 | ) |
| 4016 | if post_compile: |
| 4017 | ret = "__[POSTCOMPILE_%s]" % name |
| 4018 | if expanding: |
| 4019 | # for expanding, bound parameters or literal values will be |
| 4020 | # rendered per item |
| 4021 | return ret |
| 4022 | |
| 4023 | # otherwise, for non-expanding "literal execute", apply |
| 4024 | # bind casts as determined by the datatype |
| 4025 | if bindparam_type is not None: |
| 4026 | type_impl = bindparam_type._unwrapped_dialect_impl( |
| 4027 | self.dialect |
| 4028 | ) |
| 4029 | if type_impl.render_literal_cast: |
| 4030 | ret = self.render_bind_cast(bindparam_type, type_impl, ret) |
| 4031 | return ret |
| 4032 | elif self.state is CompilerState.COMPILING: |
| 4033 | ret = self.compilation_bindtemplate % {"name": name} |
| 4034 | else: |
| 4035 | ret = self.bindtemplate % {"name": name} |
| 4036 | |
| 4037 | if ( |
no test coverage detected