MCPcopy Index your code
hub / github.com/dbcli/mycli / _emit_where_token

Function _emit_where_token

mycli/packages/completion_engine.py:342–362  ·  view source on GitHub ↗
(ctx: SuggestContext)

Source from the content-addressed store, hash-verified

340
341
342def _emit_where_token(ctx: SuggestContext) -> list[Suggestion]:
343 assert isinstance(ctx.token, Where)
344 # sqlparse groups all tokens from the where clause into a single token
345 # list. This means that token.value may be something like
346 # 'where foo > 5 and '. We need to look "inside" token.tokens to handle
347 # suggestions in complicated where clauses correctly.
348 #
349 # This logic also needs to look even deeper in to the WHERE clause.
350 # We recapitulate some transcoding suggestions here, but cannot
351 # recapitulate the entire logic of this function.
352 where_tokens = [x for x in ctx.token.tokens if x.ttype != sqlparse.tokens.Token.Text.Whitespace]
353 if transcoding_suggestion := _charset_suggestion(where_tokens):
354 return transcoding_suggestion
355
356 original_text = ctx.text_before_cursor
357 prev_keyword, rewound_text = find_prev_keyword(ctx.text_before_cursor)
358 enum_suggestion = _enum_value_suggestion(original_text, ctx.full_text)
359 fallback = suggest_based_on_last_token(prev_keyword, rewound_text, None, ctx.full_text, ctx.identifier)
360 if enum_suggestion and _is_where_or_having(prev_keyword):
361 return [enum_suggestion] + fallback
362 return fallback
363
364
365def _emit_binary_or_comma(ctx: SuggestContext) -> list[Suggestion]:

Calls 5

find_prev_keywordFunction · 0.90
_charset_suggestionFunction · 0.85
_enum_value_suggestionFunction · 0.85
_is_where_or_havingFunction · 0.85