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:
Joseph Doherty
2026-01-06 17:00:09 -05:00
parent 87a02d5368
commit 48c96eb8f4
2 changed files with 63 additions and 4 deletions
+3 -4
View File
@@ -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)