Skip to content

[Bug]: SQL autocomplete shows table names instead of columns after alias (PostgreSQL) #266

Description

@m-tonon

Describe the bug

When writing a SELECT with a table alias and requesting completions after alias., the SQL editor suggests table names instead of column names. This happens on PostgreSQL when the table is referenced with a double-quoted identifier.

  • Area: SQL editor / Monaco autocomplete

Expected behavior

Autocomplete should list columns from "AccountEventLog" (e.g. id, created_at, …).

Actual behavior

Autocomplete lists tables in the schema (Monaco kind “Table”), not columns from the aliased table.

Image

Additional cases

The same class of bug can affect:

  • SELECT u. FROM public.users u (schema-qualified table + alias)
  • SELECT * FROM users u, orders o then o. (comma-separated FROM — second alias not parsed)
  • Any alias. where the alias was not resolved, which previously fell through to the default table suggestion list

Working case (before fix): unquoted simple tables, e.g. SELECT u. FROM users u.

Root cause

  1. parseTablesFromQuery (src/utils/sqlAnalysis.ts) only recognized unquoted identifiers and MySQL-style backticks. It did not parse PostgreSQL double-quoted table names ("AccountEventLog").
  2. The parser lowercased the entire SQL string before extraction, which broke mixed-case quoted identifiers.
  3. When alias. could not be resolved, registerSqlAutocomplete (src/utils/autocomplete.ts) did not return early and fell through to the generic table list branch.

To Reproduce

  1. Connect to a PostgreSQL database that has a mixed-case or quoted table (example: "AccountEventLog").
  2. Open the SQL editor.
  3. Type a query such as:
SELECT ael. FROM "AccountEventLog" ael
  1. Trigger autocomplete immediately after ael. (type . or invoke suggestions).

OS Version

CachyOS (Kernel 7.0.9)

Tabularis Version

v0.12.0

Relevant Log Output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions