@@ -438,13 +438,27 @@ func normalizeDefault(ctx *sql.Context, colDefault *sql.ColumnDefaultValue) (sql
438438 return colDefault , transform .SameTree , nil
439439 }
440440 typ := colDefault .Type ()
441- if types . IsTime ( typ ) || types . IsTimespan ( typ ) || types . IsEnum ( typ ) || types . IsSet ( typ ) || types . IsJSON (typ ) {
441+ if skipDefaultNormalizationForType (typ ) {
442442 return colDefault , transform .SameTree , nil
443443 }
444444 val , err := colDefault .Eval (ctx , nil )
445445 if err != nil {
446446 return colDefault , transform .SameTree , nil
447447 }
448- colDefault .Expr = expression .NewLiteral (val , typ )
449- return colDefault , transform .NewTree , nil
448+
449+ newDefault , err := colDefault .WithChildren (expression .NewLiteral (val , typ ))
450+ if err != nil {
451+ return nil , transform .SameTree , err
452+ }
453+ return newDefault , transform .NewTree , nil
454+ }
455+
456+ // skipDefaultNormalizationForType returns true if the default value for the given type should not be normalized for
457+ // serialization before being passed to the integrator for table creation
458+ func skipDefaultNormalizationForType (typ sql.Type ) bool {
459+ // Extended types handle their own serialization concerns
460+ if _ , ok := typ .(types.ExtendedType ); ok {
461+ return true
462+ }
463+ return types .IsTime (typ ) || types .IsTimespan (typ ) || types .IsEnum (typ ) || types .IsSet (typ ) || types .IsJSON (typ )
450464}
0 commit comments