Skip to content

Conversation

@pyramation
Copy link
Collaborator

No description provided.

- Add pretty option to DeparserOptions interface
- Enhance SqlFormatter with proper indentation support
- Modify CreateStmt to format with newlines and tabs when pretty=true
- Create new pretty/ test folder with snapshot tests
- Maintain backward compatibility (pretty=false by default)
- All existing tests continue to pass

Co-Authored-By: Dan Lynch <[email protected]>
…atements

- Add pretty formatting for SELECT statements with proper clause indentation
- Add pretty formatting for constraint statements with multi-line support
- Add pretty formatting for CREATE POLICY statements with clause formatting
- Create comprehensive test fixtures for all new statement types
- Add snapshot tests for SELECT, constraints, and CREATE POLICY formatting
- Maintain backward compatibility with single-line formatting when pretty=false
- All tests passing with proper snapshot validation

Co-Authored-By: Dan Lynch <[email protected]>
- Remove extra blank lines after SELECT keyword
- Fix indentation levels for FROM, LIMIT, OFFSET clauses
- Add AST validation test to ensure pretty-formatted SQL maintains semantic equivalence
- Update snapshots to match correct formatting pattern
- All pretty formatting tests now pass (SELECT, CREATE TABLE, constraints, CREATE POLICY)

Co-Authored-By: Dan Lynch <[email protected]>
- Replace custom AST validation logic with proper expectAstMatch utility from test-utils
- Update all pretty formatting tests (SELECT, CREATE TABLE, constraints, CREATE POLICY) to use expectAstMatch
- Fix CreatePolicyStmt deparser bug that was removing spaces between keywords in pretty mode
- Ensure round-trip validation: parse(sql1) → deparse(ast) → sql2 where parse(sql1) === parse(sql2) at AST level
- Update CREATE POLICY snapshots to reflect corrected formatting
- All tests pass with proper semantic equivalence validation

Co-Authored-By: Dan Lynch <[email protected]>
…comparison

- Add standalone expectParseDeparse helper function in test-utils/index.ts (not on class)
- Implement round-trip validation: parse(sql1) → deparse(sql2) → parse(sql2) → compare cleanTree(ast1) vs cleanTree(ast2)
- Replace expectAstMatch usage with expectParseDeparse in all pretty formatting tests:
  - SELECT pretty tests
  - CREATE TABLE pretty tests
  - Constraints pretty tests
  - CREATE POLICY pretty tests
- Use direct expect(ast2).toEqual(ast1) comparison for semantic validation
- All tests pass with simplified, more direct AST validation approach

Co-Authored-By: Dan Lynch <[email protected]>
- Update expectParseDeparse to return deparsed SQL for snapshot testing
- Add DeparserOptions type support for newline and tab options
- Replace all deparseSync calls with expectParseDeparse in pretty tests
- Remove separate AST validation tests - now consolidated into snapshot tests
- Each test now gets both AST validation and snapshot testing in single call
- All 4 pretty test suites (24 tests, 24 snapshots) pass with consolidated approach

Co-Authored-By: Dan Lynch <[email protected]>
- Remove unnecessary if/else conditionals where both branches do identical operations
- Simplify LIMIT and OFFSET logic while maintaining functionality
- Both pretty and non-pretty modes now use the same streamlined code path
- All tests continue to pass with simplified logic

Co-Authored-By: Dan Lynch <[email protected]>
- Add newline formatting for JOIN clauses in SELECT statements
- Improve CREATE POLICY formatting with proper USING and WITH CHECK clause indentation
- Implement CTE (Common Table Expressions) pretty formatting with proper indentation
- Add comprehensive test cases for complex SQL formatting scenarios
- Update snapshots to reflect improved formatting output
- Maintain AST equivalence through expectParseDeparse validation

Co-Authored-By: Dan Lynch <[email protected]>
…able aliases

- Fixed JoinExpr method to properly handle spaces in pretty formatting mode
- Added leading space to ON and USING clauses to maintain proper SQL syntax
- Updated snapshots to reflect improved formatting that matches Dan's requirements
- All tests passing with enhanced JOIN, CREATE POLICY, and CTE formatting

Co-Authored-By: Dan Lynch <[email protected]>
- Add containsMultilineStringLiteral helper method to detect multi-line string literals
- Preserve string literal content in SelectStmt target lists, GROUP BY, HAVING, ORDER BY clauses
- Fix WithClause CTE formatting to avoid corrupting string literals during indentation
- Resolves all 6 failing kitchen sink tests while maintaining AST equivalence

Co-Authored-By: Dan Lynch <[email protected]>
- Add detailed pretty formatting section to DEPARSER_USAGE.md
- Include complete options table with all 5 available options
- Provide clear examples for basic usage and custom formatting
- Document supported statements and semantic preservation notes
- Complete the pretty formatting feature documentation

Co-Authored-By: Dan Lynch <[email protected]>
- Add concise Options section with table of main options
- Include pretty formatting example showing before/after
- Reference full documentation in DEPARSER_USAGE.md
- Complete user-facing documentation for pretty print feature

Co-Authored-By: Dan Lynch <[email protected]>
@pyramation pyramation merged commit 797d5db into main Jun 23, 2025
1 check 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