MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / parse_defaults

Function parse_defaults

web/pgadmin/utils/sqlautocomplete/parseutils/meta.py:29–53  ·  view source on GitHub ↗

Yields default values for a function, given the string provided by pg_get_expr(pg_catalog.pg_proc.proargdefaults, 0)

(defaults_string)

Source from the content-addressed store, hash-verified

27
28
29def parse_defaults(defaults_string):
30 """Yields default values for a function, given the string provided by
31 pg_get_expr(pg_catalog.pg_proc.proargdefaults, 0)"""
32 if not defaults_string:
33 return
34 current = ""
35 in_quote = None
36 for char in defaults_string:
37 if current == "" and char == " ":
38 # Skip space after comma separating default expressions
39 continue
40 if char == '"' or char == "'":
41 if in_quote and char == in_quote:
42 # End quote
43 in_quote = None
44 elif not in_quote:
45 # Begin quote
46 in_quote = char
47 elif char == "," and not in_quote:
48 # End of expression
49 yield current
50 current = ""
51 continue
52 current += char
53 yield current
54
55
56class FunctionMetadata:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected