-
Notifications
You must be signed in to change notification settings - Fork 31
Feat/pretty #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feat/pretty #153
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- [email protected] - [email protected] - @pgsql/[email protected] - @pgsql/[email protected]
- 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]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.