-
Notifications
You must be signed in to change notification settings - Fork 31
Pretty/cast #166
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
Pretty/cast #166
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
- Add isPgCatalogType helper method to detect pg_catalog types and aliases - Modify TypeCast method to use :: syntax for pg_catalog types - Preserve CAST() syntax for qualified bpchar types to maintain AST consistency - Update test cases and snapshots for castings and pg-catalog tests - All 267 test suites pass including kitchen-sink tests Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Allow FuncCall node types to use :: syntax when casting to pg_catalog types - Successfully converts CAST(public.gen_random_uuid() AS text) to public.gen_random_uuid()::text - Updated pg-catalog test snapshot to reflect new behavior - All 267 test suites pass with no regressions Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- SELECT statements: single targets inline, multiple targets multiline - CREATE TRIGGER statements: each component on separate lines with indentation - ALTER DEFAULT PRIVILEGES statements: GRANT clause on new line with indentation - Updated test snapshots to reflect correct formatting behavior - All formatting rules only apply when isPretty() is true - Maintains backward compatibility with existing non-pretty formatting Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Implement isComplexSelectTarget method for nuanced complexity detection - Single simple targets: render inline (e.g. SELECT 1;, SELECT name;) - Single complex targets: render multiline (e.g. CASE, COALESCE with multiple args) - Multiple targets: always render multiline regardless of complexity - Complex expressions include: CASE, subqueries, functions with multiple args/clauses - Simple expressions include: literals, column refs, simple arithmetic, basic function calls - All formatting rules only apply when isPretty() is true - Maintains backward compatibility and passes all existing tests Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Replace hardcoded quote wrapping with QuoteUtils.quote() in CreatePolicyStmt and AlterPolicyStmt methods - Policy names like 'user_policy', 'admin_policy', 'simple_policy' are now correctly unquoted - Policy names with spaces or special characters (e.g. 'Simple Policy') are still properly quoted - Updated test snapshots to reflect correct quoting behavior - All 269 test suites pass with 380 tests passing Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Set isStringLiteral context for trigger function arguments in CreateTrigStmt - Ensures string literals are properly quoted with single quotes via QuoteUtils.formatEString() - Prevents automatic lowercase conversion during parse/deparse cycle - Fixes triggers-9.sql test where 'TYPE_A' was being converted to 'type_a' - Updated snapshots to reflect correct string literal formatting Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Place ADD CONSTRAINT on new line with indentation when pretty printing enabled - Maintains existing behavior for non-pretty mode - Follows existing pretty printing patterns in codebase - Updated constraint test snapshots to reflect new formatting Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Place FOREIGN KEY and REFERENCES clauses on separate lines with indentation - Improve CHECK constraint formatting for multi-line expressions with proper parentheses - Fix MATCH clause spacing to prevent 'REFERENCESfooMATCH FULL' parsing errors - Add proper indentation for NOT VALID clause in pretty printing mode - Maintain existing behavior for non-pretty mode - Follow existing pretty printing patterns in codebase Fixes kitchen-sink test failures in: - original-tables-custom.test.ts - original-upstream-foreign_key.test.ts - original-upstream-alter_table.test.ts Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Place FOREIGN KEY clause on new line after ADD CONSTRAINT in ALTER TABLE - Add proper line breaks for UNIQUE and CHECK constraints in CREATE TABLE - Maintain existing behavior for column constraints and non-pretty mode - Follow existing pretty printing patterns with newline() and indent() - Update all affected test snapshots to reflect correct formatting Fixes constraint formatting issues where table-level constraints were appearing inline instead of on separate lines when pretty printing is enabled. Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Add indentLevel property to DeparserContext interface for better indentation tracking - Fix BoolExpr formatting to use consistent 2-space indentation for AND/OR operators - Remove extra blank lines in CREATE TABLE constraint formatting - Improve CHECK constraint formatting with proper line breaks and indentation - Fix constraints-17.sql, constraints-16.sql, and constraints-9.sql formatting issues - Update test snapshots to reflect improved constraint formatting - Maintain backward compatibility for non-pretty printing modes Co-Authored-By: Dan Lynch <pyramation@gmail.com>
- Align closing parenthesis with CHECK keyword at same indentation level - Fixes constraints-16.sql formatting where closing paren was over-indented - Maintains existing functionality for other constraint types - All constraint formatting tests pass Co-Authored-By: Dan Lynch <pyramation@gmail.com>
This reverts commit 9aaa60d.
- Fix VALUES formatting to avoid corrupting string literals with escape sequences - Use containsMultilineStringLiteral() to preserve original string content - Column lists always wrapped in parentheses across multiple lines - VALUES keyword always on its own line - Each tuple indented by two spaces - Preserve quoted identifiers and schema names exactly - Update casing-pretty.test.ts snapshots with new formatting rules Co-Authored-By: Dan Lynch <pyramation@gmail.com>
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.