MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / safe_construct

Method safe_construct

lib/sqlalchemy/sql/elements.py:5991–6002  ·  view source on GitHub ↗
(
        cls, seed: int | str, body: str, sanitize_key: bool = False
    )

Source from the content-addressed store, hash-verified

5989
5990 @classmethod
5991 def safe_construct(
5992 cls, seed: int | str, body: str, sanitize_key: bool = False
5993 ) -> _anonymous_label:
5994 # need to escape chars that interfere with format
5995 # strings in any case, issue #8724
5996 body = _anonymous_label_escape.sub("_", body)
5997
5998 if sanitize_key:
5999 # sanitize_key is then an extra step used by BindParameter
6000 body = body.strip("_")
6001
6002 return _anonymous_label(f"%({seed} {body.replace('%', '%%')})s")
6003
6004 def __add__(self, other: str) -> _anonymous_label:
6005 if "%" in other and not isinstance(other, _anonymous_label):

Callers 8

_initMethod · 0.80
__init__Method · 0.80
aliasMethod · 0.80
_normalize_fromsMethod · 0.80
_anon_labelMethod · 0.80
__init__Method · 0.80
_copy_internalsMethod · 0.80
init_objectsMethod · 0.80

Calls 4

_anonymous_labelClass · 0.85
subMethod · 0.80
stripMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected