def get_completer(self, settings=None, casing=None): metadata = self.metadata from pgcli.pgcompleter import PGCompleter from pgspecial import PGSpecial comp = PGCompleter(smart_completion=True, settings=settings, pgspecial=PGSpecial()) schemata, tables, tbl_cols, views, view_cols = [], [], [], [], [] for sch, tbls in metadata["tables"].items(): schemata.append(sch) for tbl, cols in tbls.items(): tables.append((sch, tbl)) # Let all columns be text columns tbl_cols.extend( [self._make_col(sch, tbl, col) for col in cols]) for sch, tbls in metadata.get("views", {}).items(): for tbl, cols in tbls.items(): views.append((sch, tbl)) # Let all columns be text columns view_cols.extend( [self._make_col(sch, tbl, col) for col in cols]) functions = [ FunctionMetadata(sch, *func_meta, arg_defaults=None) for sch, funcs in metadata["functions"].items() for func_meta in funcs ] datatypes = [(sch, typ) for sch, datatypes in metadata["datatypes"].items() for typ in datatypes] foreignkeys = [ ForeignKey(*fk) for fks in metadata["foreignkeys"].values() for fk in fks ] comp.extend_schemata(schemata) comp.extend_relations(tables, kind="tables") comp.extend_relations(views, kind="views") comp.extend_columns(tbl_cols, kind="tables") comp.extend_columns(view_cols, kind="views") comp.extend_functions(functions) comp.extend_datatypes(datatypes) comp.extend_foreignkeys(foreignkeys) comp.set_search_path(["public"]) comp.extend_casing(casing or []) return comp
def get_completer(self, settings=None, casing=None): metadata = self.metadata from pgcli.pgcompleter import PGCompleter comp = PGCompleter(smart_completion=True, settings=settings) schemata, tables, tbl_cols, views, view_cols = [], [], [], [], [] for schema, tbls in metadata['tables'].items(): schemata.append(schema) for table, cols in tbls.items(): tables.append((schema, table)) # Let all columns be text columns tbl_cols.extend([(schema, table, col, 'text') for col in cols]) for schema, tbls in metadata.get('views', {}).items(): for view, cols in tbls.items(): views.append((schema, view)) # Let all columns be text columns view_cols.extend([(schema, view, col, 'text') for col in cols]) functions = [ FunctionMetadata(schema, *func_meta) for schema, funcs in metadata['functions'].items() for func_meta in funcs ] datatypes = [(schema, datatype) for schema, datatypes in metadata['datatypes'].items() for datatype in datatypes] foreignkeys = [ ForeignKey(*fk) for fks in metadata['foreignkeys'].values() for fk in fks ] comp.extend_schemata(schemata) comp.extend_relations(tables, kind='tables') comp.extend_relations(views, kind='views') comp.extend_columns(tbl_cols, kind='tables') comp.extend_columns(view_cols, kind='views') comp.extend_functions(functions) comp.extend_datatypes(datatypes) comp.extend_foreignkeys(foreignkeys) comp.set_search_path(['public']) comp.extend_casing(casing or []) return comp