Skip to content

fix(editor): read DELIMITER lines, COPY rows and IF ... ELSE as their clients do - #4210

Merged
datlechin merged 7 commits into
mainfrom
fix/audit-wave-5-editor
Nov 12, 2026
Merged

datlechin merged 7 commits into
mainfrom
fix/audit-wave-5-editor

Conversation

@datlechin

@datlechin datlechin commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • SQL Server: IF c S1; ELSE S2; stays one statement for Run Current, the gutter, folding and SQL import. The statement tracker can hold a ; until the next token: ELSE takes it back, anything else ends the statement there. The fail-closed gate from fix(macos): keep T-SQL blocks and rewinds whole, stop CSV sanitizing by default, and fix Stop, defaults and gate cancels across drivers #4185 is unchanged.
  • MySQL and MariaDB: the editor reads DELIMITER lines as the mysql client does. The line runs nothing, and the delimiter ends a statement anywhere in code. A ; still ends a statement where the server splits, so a custom delimiter never hides a second statement from Safe Mode or MCP. Scanner, folding, import and formatter share one SQLDelimiterDirective reader.
  • PostgreSQL family: everything after COPY ... FROM STDIN; up to the \. line belongs to the COPY and is never SQL. The editor sends the header alone, so the driver's copy-in refusal stands and no row runs. SQL import stops at that COPY before sending it, naming its line, psql and --inserts. The formatter keeps a COPY and its rows as written.
  • pg_dump's \restrict and \unrestrict lines run nothing, so a current plain dump no longer fails on its first line. The import now reads PostgreSQL with the statement tracker, so a BEGIN ATOMIC body and a rule's action list arrive whole, as in the editor.
  • A run that splits the rest of a script again after a session change (macOS and iOS) now starts past the last statement's COPY rows or delimiter, with the delimiter in force. Before, it read COPY rows as statements.
  • Autocomplete: inside a join's ON, foreign keys between the joined table and the earlier ones come first as whole conditions (o.customer_id = c.id). The ON list no longer shows a qualified column twice, and iOS keeps the column's quotes after the qualifier.
  • The statement scan moved into SQLStatementScan, one method per kind of token. New curated-only grammar fact psqlScripts (bit 41), no PluginKit change. SQLLexicalFeatureMappingTests pins the bit set, so it is updated here.
  • Docs: docs(features): DELIMITER lines, COPY rows, IF ... ELSE and join conditions docs#203

Needs the maintainer

  • Loading COPY ... FROM STDIN rows (copy-in) is not in this PR. It needs a PluginKit copy-in call on the driver and an import element that streams the rows.

Test plan

  • Package: TSQLControlFlowBlockTests, SQLDelimiterDirectiveTests, SQLPsqlScriptTests, SQLStatementCursorIndexTests (new fixtures and edits), QueryScriptTests.replanAfterACopy, SQLJoinConditionCompletionTests, SQLContextAnalyzerJoinScopeTests.
  • App: SQLFileParserTests, SQLFoldScannerTests, SQLTokenizerTests, SQLFormatterServiceTests, QueryClassifierClientScriptTests, MultiStatementReplanTests, SQLSchemaProviderTests.
  • iOS: QueryCompletionCatalogTests, QueryCompletionControllerTests.

… their clients do; join conditions from foreign keys
@datlechin
datlechin enabled auto-merge (squash) November 11, 2026 19:58
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