feat(DbExporter): add counting data reader for accurate row count
Wrap IDataReader with CountingDataReader to track rows as they're read during protobuf serialization, fixing the export returning 0 rows.
This commit is contained in:
@@ -26,7 +26,8 @@ public sealed class DatabaseExporter
|
||||
command.CommandText = definition.Query;
|
||||
command.CommandTimeout = 0; // No timeout for large exports
|
||||
|
||||
await using var reader = await command.ExecuteReaderAsync(cancellationToken);
|
||||
await using var baseReader = await command.ExecuteReaderAsync(cancellationToken);
|
||||
var reader = new CountingDataReader(baseReader);
|
||||
|
||||
long uncompressedSize = 0;
|
||||
|
||||
@@ -51,9 +52,7 @@ public sealed class DatabaseExporter
|
||||
|
||||
var compressedSize = new FileInfo(definition.OutputPath).Length;
|
||||
|
||||
// Row count requires a separate pass or we estimate from verify
|
||||
// Return 0 for now, verify will get accurate count
|
||||
return new ExportResult(0, uncompressedSize, compressedSize, hash);
|
||||
return new ExportResult(reader.RowCount, uncompressedSize, compressedSize, hash);
|
||||
}
|
||||
|
||||
private static DbConnection CreateConnection(string providerType, string connectionString)
|
||||
|
||||
Reference in New Issue
Block a user