Skip to content

Conversation

@pyramation
Copy link
Collaborator

feat: add pretty fixtures for quoting and formatting behaviors

Summary

Adds test fixtures to document deparser behavior for several SQL formatting scenarios observed in downstream repos:

Quoting fixtures (quoting.sql):

  • Reserved keyword function names (float, interval, boolean) that require quoting
  • pg_catalog."substring" with quoted identifier
  • Tests both unquoted input forms and quoted canonical forms to verify the deparser correctly quotes reserved keywords

Formatting fixtures (formatting.sql):

  • EXPLAIN with/without COSTS OFF optional keyword
  • Boolean literal formatting ('t'::boolean cast vs TRUE literal)
  • Function parameter modes (IN, OUT, INOUT) with parenthesization

Review & Testing Checklist for Human

  • Verify quoting behavior: Check that snapshots show faker.float (unquoted input) deparsing to faker."float" (quoted output) - this is the key transformation being documented
  • Verify boolean formatting: The snapshots show 't'::boolean becomes CAST('t' AS boolean) rather than TRUE - confirm this matches expected deparser behavior (differs from original diff which showed TRUE)
  • SUBSTRING limitation: Note that SUBSTRING(value FROM 'pattern') SQL syntax was excluded because it cannot round-trip (different AST representation) - only the canonical pg_catalog."substring"(value, 'pattern') form is tested

Test plan:

cd packages/deparser
pnpm test -- quoting-pretty.test.ts
pnpm test -- formatting-pretty.test.ts

Notes

Add test fixtures documenting deparser behavior for:
- Quoted function names (float, interval, boolean) as reserved keywords
- pg_catalog.substring with quoted identifier
- EXPLAIN with optional COSTS OFF keyword
- Boolean literal formatting ('t'::boolean vs TRUE)
- Parenthesization/argument formatting with IN parameter mode

Both input forms and canonical forms are included where applicable
to test both the transformation and idempotence.
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 1923251 into main Dec 25, 2025
14 checks passed
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.

2 participants