MCPcopy Create free account
hub / github.com/bytebase/bytebase / defaultValuesEqual

Function defaultValuesEqual

backend/plugin/schema/differ.go:687–705  ·  view source on GitHub ↗

defaultValuesEqual compares default values.

(col1, col2 *storepb.ColumnMetadata)

Source from the content-addressed store, hash-verified

685
686// defaultValuesEqual compares default values.
687func defaultValuesEqual(col1, col2 *storepb.ColumnMetadata) bool {
688 // Quick check for identical strings
689 if col1.Default == col2.Default {
690 return true
691 }
692
693 // Handle PostgreSQL type cast normalization for common cases before expression comparison
694 // This is needed because the expression comparer may not parse complex type casts correctly
695 normalized1 := normalizePostgreSQLTypecastInDefault(col1.Default)
696 normalized2 := normalizePostgreSQLTypecastInDefault(col2.Default)
697
698 if normalized1 == normalized2 {
699 return true
700 }
701
702 // Use semantic expression comparison for PostgreSQL default values
703 // This handles schema prefixes and other semantic equivalences
704 return CompareExpressionsSemantically(storepb.Engine_POSTGRES, col1.Default, col2.Default)
705}
706
707// normalizePostgreSQLTypecastInDefault normalizes PostgreSQL type casts in default values
708func normalizePostgreSQLTypecastInDefault(defaultValue string) string {

Callers 1

columnsEqualFunction · 0.70

Tested by

no test coverage detected