Skip to content

feat(editor): inline query diagnostics and PostgreSQL enum value completion - #2106

Merged
datlechin merged 1 commit into
mainfrom
feat/2095-diagnostics-and-enums
Aug 13, 2026
Merged

feat(editor): inline query diagnostics and PostgreSQL enum value completion#2106
datlechin merged 1 commit into
mainfrom
feat/2095-diagnostics-and-enums

Conversation

@datlechin

Copy link
Copy Markdown
Member

Closes #2095. Follow-up to #2102 and #2105, covering the last two items.

Inline diagnostics

The editor underlines a structural mistake in red as you type, through EmphasisManager, which owns its own drawing layer and needs no change to the vendored packages.

The design constraint here is restraint, not coverage. Every high-vote DataGrip inspection ticket is a false positive on SQL that runs fine, and Postico's auto-suggest request sat open since 2017 because its maintainer would not ship suggestions before they were context-sensitive enough not to annoy. So this reports only what more typing cannot fix:

Reported Deliberately silent
A closing bracket with no opener A bracket you have not closed yet
A bracket closing the wrong kind A string you are still typing
An unterminated block comment An incomplete statement

Brackets inside a string literal or comment are ignored. Checking runs 500ms after you stop typing and is skipped on large documents.

On MongoDB the parser runs too, once the structure is balanced, and reports its own reason. MongoShellParseError carries no range, so rather than underline the whole statement the producer locates the offending token where it can: an unsupported method is underlined on the method name itself, everything else falls back to the first statement line.

Why this is custom. The editor is not an NSTextView. CodeEditTextView.TextView is an NSView with a hand-rolled NSTextInputClient and its own TextLayoutManager, so NSLayoutManager.setTemporaryAttributes and NSTextLayoutManager.addRenderingAttribute are both structurally unreachable, not merely unused. EmphasisManager.underline(color:) is the seam. Also worth recording: TextKit 2 rendering attributes silently ignore underlineStyle (verified by pixel-diff, documented nowhere), so the usual "modernize the squiggle" move would have shipped an invisible diagnostic.

Not included: a gutter marker. GutterView has no per-line marker primitive, so that needs a vendored change and is better as its own PR.

PostgreSQL enum values

WHERE status = now offers the labels the enum type declares. The fetch layer already existed: PostgreSQLPluginDriver+Columns reads pg_enum into PluginColumnInfo.allowedValues and it flows to ColumnInfo. Nothing surfaced it. This adds the missing half.

The analyzer gained a comparisonColumn signal: scanning back over whitespace, a comparison operator (=, <>, !=, <, >, <=, >=, IN, LIKE, ILIKE), then an identifier, with word operators requiring a real word boundary and SQL keywords excluded so WHERE alone never counts as a column.

Value lookup is cache-only and never triggers a fetch. Completion runs on every keystroke, so the first draft, which called getColumns, would have fired a schema fetch per table per keystroke in a WHERE clause. The eager column preload is what fills the cache.

SQLContext.replacingTableReferences forwards the new field explicitly, the same trap that would have silently dropped operators from withCaseSensitivityStyle in #2102.

DataGrip completes enum values in the data-editor grid only, not the SQL editor. DBeaver reaches them by scanning user data, off by default and unimplemented in its default engine. Reading pg_enum directly in a comparison is unclaimed.

Testing

19 new diagnostics tests, weighted toward the restraint cases (a half-typed statement, an unterminated string, brackets inside strings and comments) since that is the property most likely to regress. Suites green: QueryDiagnostics, SQLContextAnalyzer, CompletionEngine, SQLSchemaProvider, MongoContextAnalyzer. swiftlint lint --strict clean across 1340 files.

One pre-existing failure to be aware of, not introduced here. SQLCompletionProviderTests has three tests (testProviderAcceptsDatabaseType, testMySQLProviderTypes, testCommaFromScopesColumnsToAllTables) that fail when the suite runs as a whole but pass individually. I verified this on clean main at 1665429d2 before and after my changes: identical failures both ways. The suite is already in .github/macos-test-quarantine.txt, so CI skips it. Flagging it because the isolation-vs-suite split suggests parallel test interference rather than the documented driver-dependency reason.

Behaviour note

MQL has no comment syntax: the parser treats a // line as part of the statement, which the MongoDB docs already state. The diagnostics scanner matches the parser, so db.users.find({}) // ) reports the unmatched bracket rather than hiding it. MongoContextAnalyzer still suppresses completion inside //, which is an advisory affordance rather than a correctness claim. Teaching the parser to strip comments the way mongosh does would remove the split, and is worth its own change.

@mintlify

mintlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟢 Ready View Preview Aug 13, 2026, 11:52 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin
datlechin merged commit 269147f into main Aug 13, 2026
4 checks passed
@datlechin
datlechin deleted the feat/2095-diagnostics-and-enums branch August 13, 2026 11:54
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.

Query authoring for MongoDB and PostgreSQL needs real autocomplete, dialect data, and diagnostics

1 participant