normalizePostgreSQLTypecastInDefault normalizes PostgreSQL type casts in default values
(defaultValue string)
| 706 | |
| 707 | // normalizePostgreSQLTypecastInDefault normalizes PostgreSQL type casts in default values |
| 708 | func normalizePostgreSQLTypecastInDefault(defaultValue string) string { |
| 709 | if defaultValue == "" { |
| 710 | return "" |
| 711 | } |
| 712 | |
| 713 | normalized := strings.TrimSpace(defaultValue) |
| 714 | |
| 715 | // Remove PostgreSQL type casts from default values |
| 716 | // Handle patterns like '1 day'::interval -> '1 day' |
| 717 | normalized = strings.ReplaceAll(normalized, "'::interval", "'") |
| 718 | normalized = strings.ReplaceAll(normalized, "'::timestamp", "'") |
| 719 | normalized = strings.ReplaceAll(normalized, "'::date", "'") |
| 720 | normalized = strings.ReplaceAll(normalized, "'::time", "'") |
| 721 | normalized = strings.ReplaceAll(normalized, "'::numeric", "'") |
| 722 | |
| 723 | // Handle string type casts |
| 724 | // Handle character varying first (longest match first to avoid partial replacement) |
| 725 | normalized = strings.ReplaceAll(normalized, "'::character varying", "'") // CHARACTER VARYING type (full form of VARCHAR) |
| 726 | normalized = strings.ReplaceAll(normalized, "'::bpchar", "'") // CHAR type |
| 727 | normalized = strings.ReplaceAll(normalized, "'::text", "'") // TEXT type |
| 728 | normalized = strings.ReplaceAll(normalized, "'::varchar", "'") // VARCHAR type |
| 729 | normalized = strings.ReplaceAll(normalized, "'::character", "'") // CHARACTER type |
| 730 | |
| 731 | return normalized |
| 732 | } |
| 733 | |
| 734 | // generationMetadataEqual compares two generation metadata structs. |
| 735 | func generationMetadataEqual(engine storepb.Engine, gen1, gen2 *storepb.GenerationMetadata) bool { |
no outgoing calls
no test coverage detected