Check strict scan only on first row.

This commit is contained in:
go-jet 2026-01-31 14:25:26 +01:00
parent eaaa328580
commit ac8d24fa5b
2 changed files with 18 additions and 15 deletions

View file

@ -241,12 +241,8 @@ func ScanOneRowToDest(scanContext *ScanContext, rows *sql.Rows, destPtr interfac
return fmt.Errorf("jet: failed to scan a row into destination, %w", err)
}
if scanContext.rowNum == 1 && GlobalConfig.StrictScan {
scanContext.EnsureEveryColumnRead() // can panic
}
if GlobalConfig.StrictFieldMapping {
scanContext.EnsureEveryFieldMapped() // can panic
if scanContext.rowNum == 1 {
scanContext.ensureStrictness()
}
return nil
@ -291,11 +287,8 @@ func queryToSlice(ctx context.Context, db Queryable, query string, args []interf
return scanContext.rowNum, err
}
if scanContext.rowNum == 1 && GlobalConfig.StrictScan {
scanContext.EnsureEveryColumnRead()
}
if scanContext.rowNum == 1 && GlobalConfig.StrictFieldMapping {
scanContext.EnsureEveryFieldMapped()
if scanContext.rowNum == 1 {
scanContext.ensureStrictness()
}
}