pgsql-parser-testing

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.

16 stars

Best use case

pgsql-parser-testing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using pgsql-parser-testing should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/pgsql-parser-testing/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/pgsql-parser-testing/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/pgsql-parser-testing/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How pgsql-parser-testing Compares

Feature / Agentpgsql-parser-testingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# PGSQL Parser Testing

Testing workflow for the pgsql-parser repository. This skill is scoped specifically to the `constructive-io/pgsql-parser` monorepo.

## When to Apply

Use this skill when:
- Working in the pgsql-parser repository
- Fixing deparser or parser issues
- Running parser/deparser tests
- Validating SQL round-trip correctness
- Adding new SQL syntax support

## Repository Structure

```
pgsql-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 utilities
```

## Testing Strategy

The pgsql-parser uses AST-level equality for correctness, not string equality:

```
parse(sql1) → ast1 → deparse(ast1) → sql2 → parse(sql2) → ast2
```

While `sql2 !== sql1` textually, a correct round-trip means `ast1 === ast2`.

### Key Principle

Exact SQL string equality is not required. The focus is on comparing resulting ASTs. Use `expectAstMatch` (deparser) or `expectPGParse` (ast package) to validate correctness.

## Development Workflow

### Initial Setup

```bash
pnpm install
pnpm build
```

### Running Tests

Run all tests:
```bash
pnpm test
```

Run tests for a specific package:
```bash
cd packages/deparser
pnpm test
```

Watch mode for rapid iteration:
```bash
cd packages/deparser
pnpm test:watch
```

Run a specific test:
```bash
pnpm test --testNamePattern="specific-test-name"
```

## Fixing Deparser Issues

### Systematic Approach

1. **One test at a time**: Focus on individual failing tests
   ```bash
   pnpm test --testNamePattern="specific-test"
   ```

2. **Always check for regressions**: After each fix, run full test suite
   ```bash
   pnpm test
   ```

3. **Build before testing**: Always rebuild after code changes
   ```bash
   pnpm build && pnpm test
   ```

4. **Clean commits**: Stage files explicitly
   ```bash
   git add packages/deparser/src/specific-file.ts
   ```

### Workflow Loop

```
Make changes → pnpm build → pnpm test --testNamePattern="target" → pnpm test (full) → commit
```

## Test Utilities

### Deparser Tests

Location: `packages/deparser/test-utils/index.ts`

```typescript
import { expectAstMatch } from '../test-utils';

it('deparses SELECT correctly', () => {
  expectAstMatch('SELECT * FROM users');
});
```

### AST Package Tests

Location: `packages/ast/test/utils/index.ts`

Uses database deparser for validation:
```typescript
import { expectPGParse } from '../test/utils';

it('round-trips through database deparser', async () => {
  await expectPGParse('SELECT * FROM users WHERE id = 1');
});
```

Note: AST tests require the database to have `deparser.expressions_array` function available.

## Common Commands

| Command | Description |
|---------|-------------|
| `pnpm build` | Build all packages |
| `pnpm test` | Run all tests |
| `pnpm test:watch` | Run tests in watch mode |
| `pnpm lint` | Run linter |
| `pnpm clean` | Clean build artifacts |

## Package-Specific Testing

### Parser Package

Tests libpg_query bindings and SQL parsing:
```bash
cd packages/parser
pnpm test
```

### Deparser Package

Tests AST-to-SQL conversion:
```bash
cd packages/deparser
pnpm test
```

### PL/pgSQL Packages

Tests PL/pgSQL parsing and deparsing:
```bash
cd packages/plpgsql-parser
pnpm test

cd packages/plpgsql-deparser
pnpm test
```

## Debugging Tips

1. **Use isolated debug scripts** for complex issues (don't commit them)

2. **Check the AST structure** when tests fail:
   ```typescript
   import { parse } from 'pgsql-parser';
   console.log(JSON.stringify(parse('SELECT 1'), null, 2));
   ```

3. **Compare ASTs visually** to understand differences:
   ```typescript
   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));
   ```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Tests fail after changes | Run `pnpm build` before `pnpm test` |
| Type errors | Check `packages/types` for type definitions |
| Shared code changes | Rebuild dependent packages |
| Snapshot mismatches | Review changes, update with `pnpm test -u` if correct |

## Important Notes

- Changes to `types` or `utils` packages may require rebuilding dependent packages
- Each package can be developed and tested independently
- The project uses Lerna for monorepo management
- Always verify no regressions before committing

## References

- Deparser testing docs: `packages/deparser/TESTING.md`
- Quoting rules: `packages/deparser/QUOTING-RULES.md`
- Deparser usage: `packages/deparser/DEPARSER_USAGE.md`
- PL/pgSQL deparser: `packages/plpgsql-deparser/AGENTS.md`

Related Skills

playwright-app-testing

16
from diegosouzapw/awesome-omni-skill

Test the Expensify App using Playwright browser automation. Use when user requests browser testing, after making frontend changes, or when debugging UI issues

performance-testing-review-multi-agent-review

16
from diegosouzapw/awesome-omni-skill

Use when working with performance testing review multi agent review

performance-testing-review-ai-review

16
from diegosouzapw/awesome-omni-skill

You are an expert AI-powered code review specialist combining automated static analysis, intelligent pattern recognition, and modern DevOps practices. Leverage AI tools (GitHub Copilot, Qodo, GPT-5, C

mobile-app-testing

16
from diegosouzapw/awesome-omni-skill

Comprehensive mobile app testing strategies for iOS and Android. Covers unit tests, UI tests, integration tests, performance testing, and test automation with Detox, Appium, and XCTest.

moai-workflow-testing

16
from diegosouzapw/awesome-omni-skill

Comprehensive development workflow specialist combining TDD, debugging, performance optimization, code review, PR review, and quality assurance into unified development workflows

k6 Performance Testing

16
from diegosouzapw/awesome-omni-skill

Modern load testing with k6 including thresholds, scenarios, and custom metrics

javascript-testing-patterns

16
from diegosouzapw/awesome-omni-skill

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use...

html-injection-testing

16
from diegosouzapw/awesome-omni-skill

This skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applications", or "test conten...

dynamic-application-security-testing

16
from diegosouzapw/awesome-omni-skill

Perform dynamic security testing against running web applications and APIs to discover vulnerabilities through active probing and fuzzing.

dotnet-testing

16
from diegosouzapw/awesome-omni-skill

Write and run .NET tests following TDD principles. Use when writing tests, implementing TDD workflow, verifying test coverage, or debugging test failures.

bun-testing

16
from diegosouzapw/awesome-omni-skill

Testing guidelines for Bun/TypeScript projects using bun:test framework. Use when writing tests, creating test files, debugging test failures, setting up mocks, or reviewing test code. Triggers on *.test.ts files, test-related questions, mocking patterns, and coverage discussions.

browser-testing

16
from diegosouzapw/awesome-omni-skill

Use when testing web applications, debugging browser console errors, automating form interactions, or verifying UI implementations. Load for localhost testing, authenticated app testing (Gmail, Notion), or recording demo GIFs. Requires Chrome extension 1.0.36+, Claude Code 2.0.73+, paid plan.