Skip to content

Commit 7365f32

Browse files
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 <pyramation@gmail.com>
1 parent 2cbd8f0 commit 7365f32

1 file changed

Lines changed: 3044 additions & 2902 deletions

File tree

0 commit comments

Comments
 (0)