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

Method safe_construct

lib/sqlalchemy/sql/elements.py:5539–5558  ·  view source on GitHub ↗
(
        cls,
        seed: int,
        body: str,
        enclosing_label: Optional[str] = None,
        sanitize_key: bool = False,
    )

Source from the content-addressed store, hash-verified

5537
5538 @classmethod
5539 def safe_construct(
5540 cls,
5541 seed: int,
5542 body: str,
5543 enclosing_label: Optional[str] = None,
5544 sanitize_key: bool = False,
5545 ) -> _anonymous_label:
5546 # need to escape chars that interfere with format
5547 # strings in any case, issue #8724
5548 body = re.sub(r"[%\(\) \$]+", "_", body)
5549
5550 if sanitize_key:
5551 # sanitize_key is then an extra step used by BindParameter
5552 body = body.strip("_")
5553
5554 label = "%%(%d %s)s" % (seed, body.replace("%", "%%"))
5555 if enclosing_label:
5556 label = "%s%s" % (enclosing_label, label)
5557
5558 return _anonymous_label(label)
5559
5560 def __add__(self, other):
5561 if "%" in other and not isinstance(other, _anonymous_label):

Callers 12

_initMethod · 0.80
__init__Method · 0.80
aliasMethod · 0.80
_normalize_fromsMethod · 0.80
_anon_labelMethod · 0.80
__init__Method · 0.80
_cloneMethod · 0.80
_convert_to_uniqueMethod · 0.80
__setstate__Method · 0.80
__init__Method · 0.80
_copy_internalsMethod · 0.80
init_objectsMethod · 0.80

Calls 3

_anonymous_labelClass · 0.85
subMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected