normalizeCheckExprString returns a normalized string representation of a CHECK constraint expression For PostgreSQL, this converts IN (a,b,c) to = ANY (ARRAY[a,b,c])
(expr parser.Expr)
| 5068 | // normalizeCheckExprString returns a normalized string representation of a CHECK constraint expression |
| 5069 | // For PostgreSQL, this converts IN (a,b,c) to = ANY (ARRAY[a,b,c]) |
| 5070 | func (g *Generator) normalizeCheckExprString(expr parser.Expr) string { |
| 5071 | if g.mode == GeneratorModePostgres { |
| 5072 | normalized := normalizeCheckExpr(expr, g.mode) |
| 5073 | // Unwrap outermost parentheses for consistent output (comparison does this too) |
| 5074 | normalized = unwrapOutermostParenExpr(normalized) |
| 5075 | // In quote-aware mode, use formatExprQuoteAware to preserve quoting in column names |
| 5076 | // In legacy mode, use parser.String for backward compatibility (no quoting in expressions) |
| 5077 | if !g.config.LegacyIgnoreQuotes { |
| 5078 | return g.formatExprQuoteAware(normalized) |
| 5079 | } |
| 5080 | return parser.String(normalized) |
| 5081 | } |
| 5082 | return parser.String(expr) |
| 5083 | } |
| 5084 | |
| 5085 | // formatExprQuoteAware formats an expression with quote-aware column name handling. |
| 5086 | // This walks the AST and uses escapeSQLIdent for column names to preserve quoting. |
no test coverage detected