def dotted_expression(self, ev, expansion=True):
        """Return completions for head.tail<tab>"""
        head, tail = ev.symbol.split('.')
        if expansion and head in self.db.tablenames() and tail == '*':
            # tablename.*<tab> -> expand all names
            matches = self.db.fieldnames(table=head, dotted=True)
            return [MonkeyString(ev.symbol, ', '.join(sorted(matches)))]
        matches = match_lists([self.db.fieldnames(dotted=True)], ev.symbol)
        if not len(matches):  # head could be a table alias TODO: parse these.
            if tail == '':
                fields = map(lambda word: head + '.' + word,
                             self.db.fieldnames())
                matches.extend(fields)
            else:
                match_lists([self.db.fieldnames()], tail, matches.append,
                            matches.sort)
        matches.sort()
        return matches
dataset/ETHPy150Open jaysw/ipydb/ipydb/completion.py/IpydbCompleter.dotted_expression/original