fix(datacopy): COUNT(*) is Int32 on SQL Server — use Convert.ToInt64

This commit is contained in:
2026-10-10 01:15:08 +03:30
parent 9b51c866c3
commit a69862fe73

View File

@@ -117,8 +117,9 @@ internal static class Program
foreach (var (_, table) in order) foreach (var (_, table) in order)
{ {
long src = (long)(await ScalarAsync(srcConn, $"SELECT COUNT(*) FROM {table}"))!; // SQL Server COUNT(*) is Int32, Postgres is Int64 — Convert handles both
long dst = (long)(await ScalarAsync(pgConn, $"SELECT COUNT(*) FROM \"{table}\""))!; long src = Convert.ToInt64(await ScalarAsync(srcConn, $"SELECT COUNT(*) FROM {table}"))!;
long dst = Convert.ToInt64(await ScalarAsync(pgConn, $"SELECT COUNT(*) FROM \"{table}\""))!;
if (src != dst) problems++; if (src != dst) problems++;
Console.WriteLine($"{(src == dst ? "OK " : "FAIL ")} {table,-28} source={src,-10} target={dst}"); Console.WriteLine($"{(src == dst ? "OK " : "FAIL ")} {table,-28} source={src,-10} target={dst}");
} }