MCPcopy Create free account
hub / github.com/dbcli/mycli / refresh_completions

Method refresh_completions

mycli/client_query.py:34–57  ·  view source on GitHub ↗
(self, reset: bool = False)

Source from the content-addressed store, hash-verified

32 def format_sqlresult(self, *args: Any, **kwargs: Any) -> Any: ...
33
34 def refresh_completions(self, reset: bool = False) -> list[SQLResult]:
35 # Cancel any in-flight schema prefetch before the completer is
36 # replaced. Loaded-schema bookkeeping is intentionally preserved
37 # so switching between already-loaded schemas does not re-fetch.
38 self.schema_prefetcher.stop()
39
40 assert self.sqlexecute is not None
41 if reset:
42 # Update the active completer's current-schema pointer right
43 # away so unqualified completions reflect a schema switch
44 # even before the background refresh finishes.
45 with self._completer_lock:
46 self.completer.set_dbname(self.sqlexecute.dbname)
47 self.completion_refresher.refresh(
48 self.sqlexecute,
49 self._on_completions_refreshed,
50 {
51 "smart_completion": self.smart_completion,
52 "supported_formats": self.main_formatter.supported_formats,
53 "keyword_casing": self.completer.keyword_casing,
54 },
55 )
56
57 return [SQLResult(status="Auto-completion refresh started in the background.")]
58
59 def _on_completions_refreshed(self, new_completer: SQLCompleter) -> None:
60 """Swap the completer object in cli with the newly created completer."""

Callers 2

_one_iterationFunction · 0.45
main_replFunction · 0.45

Calls 4

SQLResultClass · 0.90
stopMethod · 0.80
set_dbnameMethod · 0.80
refreshMethod · 0.80

Tested by

no test coverage detected