Skip to content

Fix case handling of tables in comma-separated FROM lists - #1662

Open
lee3Q wants to merge 4 commits into
dbcli:mainfrom
lee3Q:lee3Q-patch-1
Open

lee3Q wants to merge 4 commits into
dbcli:mainfrom
lee3Q:lee3Q-patch-1

Conversation

@lee3Q

@lee3Q lee3Q commented Nov 7, 2026

Copy link
Copy Markdown

Description

extract_tables handled the first table in FROM a, b differently from a single table. In the comma-separated branch of extract_table_identifiers, an IdentifierList item read the name, schema and alias straight from sqlparse (get_real_name, get_parent_name, get_alias) instead of using parse_identifier, which the single-table path uses to normalize them. Unquoted upper-case names such as USERS therefore kept their case in a list but were folded to users as a single table, so SELECT from USERS, ORDERS completed no columns while SELECT from users, orders did.

This calls parse_identifier in that branch, so both paths return the same TableReference. The change is 3 lines in pgcli/packages/parseutils/tables.py.

Tests: extract_tables for a comma list equals the combined results for each table alone (plain and PUBLIC.-qualified upper-case names, and quoted identifiers), and column completion for upper-case and quoted names in a comma list matches the single-table case (text and display_meta).

Behavior note: quoted names in a comma list now go through the same normalization as the single-table and CROSS JOIN paths, so the reference text for them can differ from what the comma path returned before.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install). I did not install the hooks. I ran ruff check and ruff format --check (ruff 0.14.10, the version pinned in .pre-commit-config.yaml) on the repository and both pass.
  • I verified that my changes work as expected (this may include manually testing them in your local environment, or in other available environments). I ran pytest tests on Linux with Python 3.10.12: without the change, the new tests give 38 failures; with it, 2751 passed, 134 skipped, 1 xfailed. Tests that need a PostgreSQL server, the behave tests and the CI matrix were not run.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

lee3Q added 4 commits November 7, 2026 18:46
Updated changelog to include new feature for handling table names in FROM lists.
Add parameterized test for identifier column completions with various table combinations.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant