Skip to content

Implement asterisk expansion feature with settings and UI integration#132

Open
Blake-goofy wants to merge 5 commits into
mainfrom
feat/asterisk-column-names
Open

Implement asterisk expansion feature with settings and UI integration#132
Blake-goofy wants to merge 5 commits into
mainfrom
feat/asterisk-column-names

Conversation

@Blake-goofy

@Blake-goofy Blake-goofy commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Implemented John's suggested idea from #103

Summary

Adds configurable SELECT * expansion from the query editor. When enabled, placing the cursor immediately after * and pressing the configured trigger key replaces the asterisk with the resolved column list.

Capabilities

  • Configurable trigger key in Settings: Tab, Enter, or Shift+Enter.
  • Coexists with snippet expansion; snippets get first chance on shared trigger keys.
  • Supports plain SELECT * FROM table.
  • Supports SELECT existing_column, * FROM table.
  • Supports temp tables declared earlier in the editor with CREATE TABLE #temp (...).
  • Supports joined tables for SELECT *.
  • Supports prior simple SELECT INTO #temp statements when the output columns can be inferred from the select list or resolved metadata.
  • Qualifies duplicate column names using:
    -- table alias when present, like t.[HireDate]
    -- table name when no alias exists, like [#Employees].[HireDate]
  • Supports alias.* by expanding only that table’s columns.
  • Falls back to metadata discovery when direct table-column lookup is not available.

Notes

  • Opt-in only; not enabled by default.
  • Requires a live SQL Server connection for metadata lookup.
  • Table variables declared earlier in the same batch are resolved directly from their DECLARE @table TABLE definition.
  • CTEs are resolved directly for explicit column lists, simple projected columns, aliases, chained CTEs, and CTE SELECT * over resolvable sources.
  • Asterisk expansion inside CTE bodies is supported for resolvable sources.
  • Derived tables are still best-effort and may require metadata fallback.
  • Only replays prior CREATE TABLE #temp statements, not arbitrary previous SQL.
  • Does not support SELECT INTO shapes that depend on dynamic SQL, stored procedures, conditional execution, or later
  • Does not account for later ALTER TABLE #temp changes.
  • Complex query shapes may fall back to SET FMTONLY ON, which is deprecated and imperfect.
  • FMTONLY fallback is only used for the outer selected statement, not for asterisk expansion inside CTE bodies.
  • Does not use SSMS IntelliSense internals; it relies on ScriptDom plus SQL Server metadata.
  • If metadata cannot be resolved, expansion fails closed and the original key behavior continues.

Open questions

  • I put the settings in Code Snippets sections; should asterisk expansion have its own section?
  • Should there be more settings like: always include alias / table name, etc. ?

@Blake-goofy Blake-goofy marked this pull request as ready for review July 5, 2026 20:18
@Blake-goofy Blake-goofy requested a review from alex-bochkov July 5, 2026 20:18
@alex-bochkov

Copy link
Copy Markdown
Contributor

@Blake-goofy Great job getting this done. Let me take a look at it this week.

@alex-bochkov

Copy link
Copy Markdown
Contributor

@Blake-goofy A few things:

  • My first instinct was to press Ctrl+Space after * to trigger the feature. Could you please add this option?
  • The Replace... checkbox in settings should be disabled when snippets are not enabled. The user must enable both options if they want the * expansion.
  • Below are a few examples where the table alias is not added correctly.

Overall, it looks great!

image image image

@Blake-goofy

Copy link
Copy Markdown
Collaborator Author

@alex-bochkov I see the issue with the first example. That is a scenario I did not consider; good catch.
What is the issue with the second example? Are you expecting the alias to always be applied? Right now it only uses alias / table name to avoid ambiguity or when the user writes alias before the *.

@alex-bochkov

Copy link
Copy Markdown
Contributor

When a query references only a single table, it's fine to list columns without a table alias. However, once two or more tables are involved, we should qualify all columns with their table aliases. This is generally considered a best practice and makes the code easier to read and maintain.

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.

2 participants