diff --git a/changelog.md b/changelog.md index b961d394..1e333ee4 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ Features * Right-align numeric columns, and make the behavior configurable. +Bug Fixes +-------- +* Better respect case when `keyword_casing` is `auto`. + + 1.47.0 (2026/01/24) ============== diff --git a/mycli/sqlcompleter.py b/mycli/sqlcompleter.py index 4834d22c..3d20ffeb 100644 --- a/mycli/sqlcompleter.py +++ b/mycli/sqlcompleter.py @@ -1027,7 +1027,7 @@ def find_matches( completions.append(item) if casing == "auto": - casing = "lower" if last and last[-1].islower() else "upper" + casing = "lower" if last and (last[0].islower() or last[-1].islower()) else "upper" def apply_case(kw: str) -> str: if casing == "upper": diff --git a/test/test_smart_completion_public_schema_only.py b/test/test_smart_completion_public_schema_only.py index 30aba328..ae220b0a 100644 --- a/test/test_smart_completion_public_schema_only.py +++ b/test/test_smart_completion_public_schema_only.py @@ -544,3 +544,15 @@ def test_file_name_completion(completer, complete_event, text, expected): result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event)) expected = [Completion(txt, pos) for txt, pos in expected] assert result == expected + + +def test_auto_case_heuristic(completer, complete_event): + text = "select jon_" + position = len("select jon_") + result = list(completer.get_completions(Document(text=text, cursor_position=position), complete_event)) + assert [x.text for x in result] == [ + 'json_table', + 'json_value', + 'join', + 'json', + ]