Semicolons
Take a string with multiple Postgres SQL statements, separated by semicolons, and split it into its constituent statements
Install / Use
/learn @neondatabase/SemicolonsREADME
semicolons
This package exists to take a string containing multiple Postgres SQL statements, separated by semicolons, and split it into its constituent statements.
This isn't trivial, because semicolons may occur in double-quoted identifiers, ordinary strings, 'escape' strings, continuation strings, dollar-quoted strings, single-line comments, and (nestable) multi-line comments, and in all these cases they do not separate statements.
Sticky RegExps are used liberally.
Developed for and used by Neon's SQL Editor. Kick the tyres there or at https://semicolons.pages.dev/.
Installation
npm install postgres-semicolons
Usage
The exported functions have comprehensive TSDoc comments in index.ts.
An example:
import * as semicolons from 'postgres-semicolons';
const sql = `BEGIN; /*/* SELECT 1; */ SELECT 2; */; SELECT ';'';'; SELECT $x$;$x$; -- COMMIT;`;
const standardConformingStrings = true;
const splits = semicolons.parseSplits(sql, standardConformingStrings);
const queries = semicolons.nonEmptyStatements(sql, splits.positions);
console.log(queries); // -> [ 'BEGIN', "SELECT ';'';'", 'SELECT $x$;$x$' ]
License
The code is MIT licensed.
Related Skills
oracle
349.2kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
349.2kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
109.5kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
109.5kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
