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)
| 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 |
no test coverage detected