MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / esc

Function esc

lib/sqlalchemy/dialects/postgresql/hstore.py:410–418  ·  view source on GitHub ↗
(s: Optional[str], position: str)

Source from the content-addressed store, hash-verified

408 """
409
410 def esc(s: Optional[str], position: str) -> str:
411 if position == "value" and s is None:
412 return "NULL"
413 elif isinstance(s, str):
414 return '"%s"' % s.replace("\\", "\\\\").replace('"', r"\"")
415 else:
416 raise ValueError(
417 "%r in %s position is not a string." % (s, position)
418 )
419
420 return ", ".join(
421 "%s=>%s" % (esc(k, "key"), esc(v, "value")) for k, v in val.items()

Callers 1

_serialize_hstoreFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected