Loading...
Loading...
Compare original and translation side by side
constructive-io/pgsql-parserconstructive-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 utilitiespgsql-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 === ast2parse(sql1) → ast1 → deparse(ast1) → sql2 → parse(sql2) → ast2sql2 !== sql1ast1 === ast2expectAstMatchexpectPGParseexpectAstMatchexpectPGParsepnpm install
pnpm buildpnpm install
pnpm buildpnpm testcd packages/deparser
pnpm testcd packages/deparser
pnpm test:watchpnpm test --testNamePattern="specific-test-name"pnpm 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.tspnpm 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) → commit修改代码 → pnpm build → pnpm test --testNamePattern="目标测试名" → 运行全量pnpm test → 提交packages/deparser/test-utils/index.tsimport { expectAstMatch } from '../test-utils';
it('deparses SELECT correctly', () => {
expectAstMatch('SELECT * FROM users');
});packages/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_arraypackages/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/parser
pnpm testcd packages/deparser
pnpm testcd packages/deparser
pnpm testcd packages/plpgsql-parser
pnpm test
cd packages/plpgsql-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));import { parse } from 'pgsql-parser';
console.log(JSON.stringify(parse('SELECT 1'), null, 2));const ast1 = parse(sql1);
const ast2 = parse(deparse(ast1));
console.log('原始AST:', JSON.stringify(ast1, null, 2));
console.log('往返转换后AST:', 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 |
| 问题 | 解决方案 |
|---|---|
| 修改代码后测试失败 | 运行 |
| 类型错误 | 检查 |
| 公共代码修改 | 重新构建依赖该公共代码的包 |
| 快照不匹配 | 核查修改内容,确认正确后执行 |
typesutilstypesutilspackages/deparser/TESTING.mdpackages/deparser/QUOTING-RULES.mdpackages/deparser/DEPARSER_USAGE.mdpackages/plpgsql-deparser/AGENTS.mdpackages/deparser/TESTING.mdpackages/deparser/QUOTING-RULES.mdpackages/deparser/DEPARSER_USAGE.mdpackages/plpgsql-deparser/AGENTS.md