@@ -570,7 +570,7 @@ func (i *modifyColumnIter) rewriteTable(ctx *sql.Context, rwt sql.RewritableTabl
570
570
}
571
571
}
572
572
573
- newRow , err := projectRowWithTypes (ctx , newSch , projections , r )
573
+ newRow , err := projectRowWithTypes (ctx , targetSchema , newSch , projections , r )
574
574
if err != nil {
575
575
_ = inserter .DiscardChanges (ctx , err )
576
576
_ = inserter .Close (ctx )
@@ -905,21 +905,21 @@ func (i *loggingKeyValueIter) Close(ctx *sql.Context) error {
905
905
906
906
// projectRowWithTypes projects the row given with the projections given and additionally converts them to the
907
907
// 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 ) {
909
909
newRow , err := ProjectRow (ctx , projections , r )
910
910
if err != nil {
911
911
return nil , err
912
912
}
913
913
914
914
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 )
916
916
if err != nil {
917
917
if sql .ErrNotMatchingSRID .Is (err ) {
918
- err = sql .ErrNotMatchingSRIDWithColName .New (sch [i ].Name , err )
918
+ err = sql .ErrNotMatchingSRIDWithColName .New (newSchema [i ].Name , err )
919
919
}
920
920
return nil , err
921
921
} 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 )
923
923
}
924
924
newRow [i ] = converted
925
925
}
0 commit comments