fix(dsync): dry-run 预演查主键存在性给准确新增/更新预估——原先一律算新增,幂等重导时预估虚高误导
This commit is contained in:
parent
35258f3b9c
commit
8be4e8f940
@ -303,7 +303,18 @@ def cmd_import(pkg_file, dry_run=False):
|
||||
stats["org_skipped"] += 1
|
||||
continue
|
||||
if dry_run:
|
||||
n_i += 1
|
||||
# 预演也查存在性,给出准确的新增/更新预估
|
||||
ex = False
|
||||
if pk:
|
||||
where = " AND ".join("`%s`=%%s" % c for c in pk)
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT 1 FROM `%s` WHERE %s LIMIT 1" % (tbl, where),
|
||||
tuple(str(row.get(c, "")) for c in pk))
|
||||
ex = cur.fetchone() is not None
|
||||
if ex:
|
||||
n_u += 1
|
||||
else:
|
||||
n_i += 1
|
||||
continue
|
||||
res = upsert_row(conn, tbl, pk, row, tcols)
|
||||
stats[res if res in stats else "skipped"] += 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user