MCPcopy Index your code
hub / github.com/dbcli/pgcli / alias

Method alias

pgcli/pgcompleter.py:547–562  ·  view source on GitHub ↗

Generate a unique table alias tbl - name of the table to alias, quoted if it needs to be tbls - TableReference iterable of tables already in query

(self, tbl, tbls)

Source from the content-addressed store, hash-verified

545 return self.find_matches(word_before_cursor, flat_cols(), meta="column")
546
547 def alias(self, tbl, tbls):
548 """Generate a unique table alias
549 tbl - name of the table to alias, quoted if it needs to be
550 tbls - TableReference iterable of tables already in query
551 """
552 tbl = self.case(tbl)
553 tbls = {normalize_ref(t.ref) for t in tbls}
554 if self.generate_aliases:
555 tbl = generate_alias(self.unescape_name(tbl), alias_map=self.alias_map)
556 if normalize_ref(tbl) not in tbls:
557 return tbl
558 elif tbl[0] == '"':
559 aliases = ('"' + tbl[1:-1] + str(i) + '"' for i in count(2))
560 else:
561 aliases = (tbl + str(i) for i in count(2))
562 return next(a for a in aliases if normalize_ref(a) not in tbls)
563
564 def get_join_matches(self, suggestion, word_before_cursor):
565 tbls = suggestion.table_refs

Callers 3

get_join_matchesMethod · 0.95
_make_candMethod · 0.95

Calls 4

caseMethod · 0.95
unescape_nameMethod · 0.95
normalize_refFunction · 0.85
generate_aliasFunction · 0.85