From 29be2582da995dd4b43f0a4ee67c8d7ddfff874b Mon Sep 17 00:00:00 2001 From: Lee Sang Gyu Date: Sat, 7 Nov 2026 18:46:55 +0900 Subject: [PATCH 1/4] Add a changelog entry for comma-separated FROM table names Updated changelog to include new feature for handling table names in FROM lists. --- changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.rst b/changelog.rst index fc362092b..6175277ef 100644 --- a/changelog.rst +++ b/changelog.rst @@ -16,6 +16,8 @@ Bug fixes: created by ``uv venv``. * Read ``alias_map_file`` as UTF-8 (with or without a BOM) instead of the locale encoding, which made non-ASCII aliases fail on Windows. +* Treat table names in a comma-separated ``FROM`` list the same way as a single + table name, so upper-case names are folded like they are for one table. Internal: --------- From cdb6fce32d847db313e92517e86f7a11b90fb437 Mon Sep 17 00:00:00 2001 From: Lee Sang Gyu Date: Sat, 7 Nov 2026 18:47:20 +0900 Subject: [PATCH 2/4] Reuse parse_identifier for comma-separated FROM tables --- pgcli/packages/parseutils/tables.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pgcli/packages/parseutils/tables.py b/pgcli/packages/parseutils/tables.py index 4c1c71a1f..45d0f8116 100644 --- a/pgcli/packages/parseutils/tables.py +++ b/pgcli/packages/parseutils/tables.py @@ -106,13 +106,12 @@ def parse_identifier(item): # Sometimes Keywords (such as FROM ) are classified as # identifiers which don't have the get_real_name() method. try: - schema_name = identifier.get_parent_name() - real_name = identifier.get_real_name() + schema_name, real_name, alias = parse_identifier(identifier) is_function = allow_functions and _identifier_is_function(identifier) except AttributeError: continue if real_name: - yield TableReference(schema_name, real_name, identifier.get_alias(), is_function) + yield TableReference(schema_name, real_name, alias, is_function) elif isinstance(item, Identifier): schema_name, real_name, alias = parse_identifier(item) is_function = allow_functions and _identifier_is_function(item) From ee8129ccf911ff508e9d4696543ef14271371adb Mon Sep 17 00:00:00 2001 From: Lee Sang Gyu Date: Sat, 7 Nov 2026 18:47:40 +0900 Subject: [PATCH 3/4] Test comma-separated table name case folding in extract_tables --- tests/parseutils/test_parseutils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/parseutils/test_parseutils.py b/tests/parseutils/test_parseutils.py index d1221f86e..598fc5542 100644 --- a/tests/parseutils/test_parseutils.py +++ b/tests/parseutils/test_parseutils.py @@ -325,3 +325,27 @@ def test_is_destructive_unconditional_update_string_literal(sql, expected): ) def test_parse_destructive_warning(warning_level, expected): assert parse_destructive_warning(warning_level) == expected + + +@pytest.mark.parametrize('schema', ['', 'PUBLIC.']) +def test_extract_tables_comma_list_matches_standalone_case_folding(schema): + first = schema + 'USERS' + second = schema + 'ORDERS' + assert extract_tables(f'SELECT * FROM {first}, {second}') == ( + extract_tables(f'SELECT * FROM {first}') + extract_tables(f'SELECT * FROM {second}') + ) + + +@pytest.mark.parametrize( + "identifier", + [ + '"public"."users"', + '"PUBLIC"."USERS"', + '"Foo"', + 'users "Alias"', + 'users "alias"', + '"users"', + ], +) +def test_comma_list_quoted_identifier_matches_standalone(identifier): + assert extract_tables(f"SELECT * FROM {identifier}, orders")[0] == extract_tables(f"SELECT * FROM {identifier}")[0] From 07522d8cc8d0652dc81e51f372a91b30fb9e3cb7 Mon Sep 17 00:00:00 2001 From: Lee Sang Gyu Date: Sat, 7 Nov 2026 18:48:02 +0900 Subject: [PATCH 4/4] Test column completion for comma-separated FROM tables Add parameterized test for identifier column completions with various table combinations. --- ...est_smart_completion_public_schema_only.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_smart_completion_public_schema_only.py b/tests/test_smart_completion_public_schema_only.py index d607dfae0..0ffa47126 100644 --- a/tests/test_smart_completion_public_schema_only.py +++ b/tests/test_smart_completion_public_schema_only.py @@ -1021,3 +1021,24 @@ def test_special_name_completion(completer): display_meta="Toggle timing of commands.", ) ]) + + +@parametrize("completer", completers(casing=False, qualify=no_qual)) +@parametrize( + "tables", + [ + ("USERS", "ORDERS"), + ('"PUBLIC"."USERS"', "ORDERS"), + ('"Foo"', "orders"), + ('"users"', 'orders'), + ('"Users"', 'orders'), + ('"public"."users"', '"public".orders'), + ('users "Alias"', 'orders "Other"'), + ('users "alias"', 'orders "other"'), + ], +) +def test_comma_list_preserves_identifier_column_completions(completer, tables): + first, second = tables + comma = get_result(completer, f"SELECT from {first}, {second}", len("SELECT ")) + joined = get_result(completer, f"SELECT from {first} CROSS JOIN {second}", len("SELECT ")) + assert completions_to_set(comma) == completions_to_set(joined)