MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / alias

Method alias

mssqlcli/mssqlcompleter.py:552–567  ·  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

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

Callers 2

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

Tested by

no test coverage detected