Skip to content

Improve split statement regex, pagination and result messages - #4

Open
dnlw07 wants to merge 3 commits into
lucashancock:masterfrom
dnlw07:master
Open

Improve split statement regex, pagination and result messages#4
dnlw07 wants to merge 3 commits into
lucashancock:masterfrom
dnlw07:master

Conversation

@dnlw07

@dnlw07 dnlw07 commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • Add src/ls/splitStatements.ts: a quote/comment-aware SQL statement
    splitter that tracks BEGIN/CASE/IF/WHILE/FOR/LOOP/REPEAT nesting depth,
    so multi-statement scripts and PL/SQL-style blocks split correctly.
  • Rework src/ls/driver.ts:
    • open() connects asynchronously via callback and, if
      connectionInitSql is set on the connection, runs it once after
      connecting (e.g. SET CURRENT SCHEMA/PATH), failing loudly and
      closing the connection if the init script errors.
    • close() closes the connection asynchronously via callback instead
      of closeSync().
    • query() now splits input with splitStatements, normalizes
      CRLF/CR line endings, and distinguishes result-set statements
      (SELECT/WITH/VALUES/CALL/DESCRIBE/EXPLAIN/XQUERY) from DML/DDL,
      executing each via queryResult or prepare + executeNonQuery
      as appropriate.
    • Added pagination for a lone SELECT/WITH statement: exact
      COUNT(*) (cached per query/tab, refreshed on page 0) with a
      look-ahead fallback when the COUNT wrapper isn't accepted.
    • Richer result messaging: affected-row counts for DML/DDL, "0 rows
      returned" for empty result sets, elapsed time in all messages.
    • Removed a debug log that printed the full connection string
      (including the plaintext password) on every connect.
  • Add connectionInitSql to connection.schema.json / ui.schema.json
    (rendered as a textarea in the connection form).
  • Update README.md (Windows install path, issues link, expanded
    build prerequisites) and bump package.json version to 0.0.4.

Test plan

  • npm run compile / tsc --noEmit passes
  • Connect to a Db2 database with and without connectionInitSql set
  • Run a plain SELECT and confirm pagination (next/prev page) works
  • Run a multi-statement script (DDL + DML) and confirm each statement
    reports the correct affected-row message
  • Run a script containing a BEGIN ... END block and confirm it is
    not split mid-block

dnlw07 added 3 commits July 18, 2026 12:38
queryResult/prepare+executeNonQuery, and SELECT/WITH pagination with
cached exact row counts. Add an optional connectionInitSql field that
runs once after connect. Drop a log line that printed the connection
string (including password) in plaintext.
…adingNoise() logic between splitStatements() and driver.ts instead of duplicating it.
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