Loading...
Loading...
Test the pgsql-parser repository (SQL parser/deparser). Use when working in the pgsql-parser repo, fixing deparser issues, running parser tests, or validating SQL round-trips. Scoped specifically to the constructive-io/pgsql-parser repository.
npx skill4agent add constructive-io/constructive-skills pgsql-parser-testingconstructive-io/pgsql-parserpgsql-parser/
packages/
parser/ # SQL parser (libpg_query bindings)
deparser/ # SQL deparser (AST to SQL)
plpgsql-parser/ # PL/pgSQL parser
plpgsql-deparser/ # PL/pgSQL deparser
types/ # TypeScript type definitions
utils/ # Utility functions
traverse/ # AST traversal utilities
transform/ # AST transformation utilitiesparse(sql1) → ast1 → deparse(ast1) → sql2 → parse(sql2) → ast2sql2 !== sql1ast1 === ast2expectAstMatchexpectPGParsepnpm install
pnpm buildpnpm testcd packages/deparser
pnpm testcd packages/deparser
pnpm test:watchpnpm test --testNamePattern="specific-test-name"pnpm test --testNamePattern="specific-test"pnpm testpnpm build && pnpm testgit add packages/deparser/src/specific-file.tsMake changes → pnpm build → pnpm test --testNamePattern="target" → pnpm test (full) → commitpackages/deparser/test-utils/index.tsimport { expectAstMatch } from '../test-utils';
it('deparses SELECT correctly', () => {
expectAstMatch('SELECT * FROM users');
});packages/ast/test/utils/index.tsimport { expectPGParse } from '../test/utils';
it('round-trips through database deparser', async () => {
await expectPGParse('SELECT * FROM users WHERE id = 1');
});deparser.expressions_array| Command | Description |
|---|---|
| Build all packages |
| Run all tests |
| Run tests in watch mode |
| Run linter |
| Clean build artifacts |
cd packages/parser
pnpm testcd packages/deparser
pnpm testcd packages/plpgsql-parser
pnpm test
cd packages/plpgsql-deparser
pnpm testimport { parse } from 'pgsql-parser';
console.log(JSON.stringify(parse('SELECT 1'), null, 2));const ast1 = parse(sql1);
const ast2 = parse(deparse(ast1));
console.log('Original:', JSON.stringify(ast1, null, 2));
console.log('Round-trip:', JSON.stringify(ast2, null, 2));| Issue | Solution |
|---|---|
| Tests fail after changes | Run |
| Type errors | Check |
| Shared code changes | Rebuild dependent packages |
| Snapshot mismatches | Review changes, update with |
typesutilspackages/deparser/TESTING.mdpackages/deparser/QUOTING-RULES.mdpackages/deparser/DEPARSER_USAGE.mdpackages/plpgsql-deparser/AGENTS.md