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)
| 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 |