diff --git a/changelog.md b/changelog.md index eb245d70..a71f75a6 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ Features Bug Fixes -------- * Fix timediff output when the result is a negative value (#1113). +* Don't offer completions for numeric text. 1.46.0 (2026/01/22) diff --git a/mycli/sqlcompleter.py b/mycli/sqlcompleter.py index 9cab2918..4834d22c 100644 --- a/mycli/sqlcompleter.py +++ b/mycli/sqlcompleter.py @@ -961,7 +961,10 @@ def find_matches( # unicode support not possible without adding the regex dependency case_change_pat = re.compile("(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])") - completions = [] + completions: list[str] = [] + + if re.match(r'^[\d\.]', text): + return (Completion(x, -len(text)) for x in completions) if fuzzy: regex = ".{0,3}?".join(map(re.escape, text)) diff --git a/test/test_smart_completion_public_schema_only.py b/test/test_smart_completion_public_schema_only.py index 4567f815..30aba328 100644 --- a/test/test_smart_completion_public_schema_only.py +++ b/test/test_smart_completion_public_schema_only.py @@ -500,6 +500,13 @@ def test_deleted_keyword_completion(completer, complete_event): ] +def test_numbers_no_completion(completer, complete_event): + text = "SELECT COUNT(1) FROM time_zone WHERE Time_zone_id = 1" + position = len("SELECT COUNT(1) FROM time_zone WHERE Time_zone_id = 1") + result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event)) + assert result == [] # ie not INT1 + + def dummy_list_path(dir_name): dirs = { "/": [