Commit 7365f32
Refactor TypeCast deparser to use AST-driven logic instead of string inspection
- Add helper functions for AST predicates:
- isQualifiedName: Check if names array matches expected path
- isBuiltinPgCatalogType: Check if type is built-in pg_catalog type
- normalizeTypeName: Extract normalized type name from TypeName node
- argumentNeedsCastSyntax: Determine if argument needs CAST() syntax based on AST structure
- Replace string-based heuristics (arg.includes('('), arg.startsWith('-')) with AST node type checks
- Detect negative numbers in A_Const nodes by checking ival/fval values directly
- Preserve round-trip fidelity for bpchar and negative number casts
- Use CAST() syntax for negative numbers to avoid precedence issues
- Maintain same output behavior as before while using pure AST logic
Test results: Reduced failures from 43 to 3 (all snapshot updates, no AST mismatches)
Co-Authored-By: Dan Lynch <[email protected]>1 parent 2cbd8f0 commit 7365f32
1 file changed
+3044
-2902
lines changed
0 commit comments