@@ -570,7 +570,7 @@ func (i *modifyColumnIter) rewriteTable(ctx *sql.Context, rwt sql.RewritableTabl
570570 }
571571 }
572572
573- newRow , err := projectRowWithTypes (ctx , newSch , projections , r )
573+ newRow , err := projectRowWithTypes (ctx , targetSchema , newSch , projections , r )
574574 if err != nil {
575575 _ = inserter .DiscardChanges (ctx , err )
576576 _ = inserter .Close (ctx )
@@ -905,21 +905,21 @@ func (i *loggingKeyValueIter) Close(ctx *sql.Context) error {
905905
906906// projectRowWithTypes projects the row given with the projections given and additionally converts them to the
907907// corresponding types found in the schema given, using the standard type conversion logic.
908- func projectRowWithTypes (ctx * sql.Context , sch sql.Schema , projections []sql.Expression , r sql.Row ) (sql.Row , error ) {
908+ func projectRowWithTypes (ctx * sql.Context , oldSchema , newSchema sql.Schema , projections []sql.Expression , r sql.Row ) (sql.Row , error ) {
909909 newRow , err := ProjectRow (ctx , projections , r )
910910 if err != nil {
911911 return nil , err
912912 }
913913
914914 for i := range newRow {
915- converted , inRange , err := sch [i ].Type . Convert ( ctx , newRow [i ])
915+ converted , inRange , err := types . TypeAwareConversion ( ctx , newRow [i ], oldSchema [ i ] .Type , newSchema [i ]. Type )
916916 if err != nil {
917917 if sql .ErrNotMatchingSRID .Is (err ) {
918- err = sql .ErrNotMatchingSRIDWithColName .New (sch [i ].Name , err )
918+ err = sql .ErrNotMatchingSRIDWithColName .New (newSchema [i ].Name , err )
919919 }
920920 return nil , err
921921 } else if ! inRange {
922- return nil , sql .ErrValueOutOfRange .New (newRow [i ], sch [i ].Type )
922+ return nil , sql .ErrValueOutOfRange .New (newRow [i ], newSchema [i ].Type )
923923 }
924924 newRow [i ] = converted
925925 }
0 commit comments