Skip to content

feat(ios): suggest tables, columns and keywords in the query editor - #3690

Merged
datlechin merged 3 commits into
mainfrom
feat/ios-query-autocomplete
Oct 20, 2026
Merged

datlechin merged 3 commits into
mainfrom
feat/ios-query-autocomplete

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • iOS query editor: suggestions in the bar above the keyboard, in front of the fixed keys, updated on every keystroke and caret move. Tables and views after FROM, JOIN, INTO, UPDATE; the statement's columns after SELECT, WHERE, ON, SET and alias.; keywords elsewhere.
  • Tapping a chip replaces the word being typed. Names are quoted per engine (quote character, reserved words, PostgreSQL lowercase and Oracle uppercase folding); inside a typed quote the name goes inside it.
  • iPad hardware keyboard: Tab inserts the first suggestion, Escape hides the bar. Both apply only while suggestions show.
  • Tables come from the connection's table list. Columns are read per table on first use and again after a run. No read starts while a run streams, and a run waits for reads already sent.
  • TableProAutocomplete moves from TableProMacCore to TableProCore. SQLCompletionProvider (what is offered where, and the ranking) moves into it behind SQLCompletionCatalog, so both apps complete the same way. Mac adapters keep the existing calls.
  • The analyzer reads the statement through TableProSQLGrammar instead of its own quote toggles. Both apps:
    • an apostrophe in a comment, a backslash in a string, or a quoted table name no longer stops completion
    • quoted and [a].[b] references resolve
    • UPDATE t SET no longer reads SET as an alias
  • Mac: "ord|" on PostgreSQL and the auto-closed [ord|] on SQL Server now complete inside the quotes.
  • Fixed keys keep their own width instead of all matching the widest.

Test plan

Fail on main, pass here:

  • swift test TableProCore: SQLContextAnalyzerLexicalTests, SQLContextAnalyzerQuotedReferenceTests, SQLCompletionProviderCatalogTests (SELECT * FROM or leads with orders, o. after FROM orders o gives its columns), SQLCompletionWindowTests, new SQLTokenBoundaryTests cases.
  • Mac hosted: SQLCompletionServiceTokenStartTests.
  • iOS: CompletionIdentifierQuotingTests, QueryCompletionCatalogTests, QueryCompletionControllerTests, SQLEditorTextViewKeyCommandTests.

Mac completes as before: the 22 Mac completion suites pass unchanged.

Tests changed on purpose:

  • SQLContextAnalyzerTests.unterminatedDoubleQuoteReadsAsAString is now an ANSI identifier-prefix case. MySQL keeps the string reading.
  • QueryCompletionControllerTests.noReadWhileRunning: a run's end no longer reads columns by itself. A read then would replace the run's row count and warnings on the session.

Real build, iPhone 18 Pro simulator, Chinook sample database:

  • SELECT * FROM Inv offers Invoice and InvoiceLine.
  • SELECT * FROM Invoice i WHERE i. offers Invoice's columns, also on first focus of restored text.
Light Dark
Before Before, light Before, dark
After After, light After, dark
After, columns After, columns, light After, columns, dark

Not in this PR

  • Mac, existing: accepting Order Details at [Order Det|] replaces only Det. tokenStart stops at the space (SQLTokenBoundary.walkBack); changing it moves the Mac's live re-rank token.
  • iOS: one driver session per connection. A column read from a keystroke between a run and SELECT ROW_COUNT() or SHOW WARNINGS replaces what the run left, as the Data tab's fetchColumns already does (DataBrowserViewModel.swift:138).
  • iOS: DDL run in the Query tab does not refresh the table list (ConnectionCoordinator.swift:342).
  • iOS: no engine functions, operators, schema names or enum values in suggestions yet (SQLBuilder.swift:357).
  • iOS: a column read while a Data tab page streams on the same PostgreSQL driver ends that page (DataBrowserViewModel.swift:145-147).
  • Both: past the 5,000-unit window, a cut inside a comment or dollar body reads its tail as code (SQLCompletionService.swift:67-69).

Fixes #3633

…mplete

# Conflicts:
#	apple/TableProMobile/TableProMobile/Views/Components/SQLHighlightTextView.swift
#	apple/TableProMobile/TableProMobile/Views/QueryEditorView.swift
@datlechin
datlechin disabled auto-merge October 20, 2026 04:33
@datlechin
datlechin merged commit e1b11a1 into main Oct 20, 2026
8 checks passed
@datlechin
datlechin deleted the feat/ios-query-autocomplete branch October 20, 2026 05:30
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.

Autocomplete in the iOS query editor

1 participant