← back to Nationalrealestate
TK-10139: fix recorder change-detection — pg returns BIGINT ids as strings; compare id fields as strings so unchanged broker/firm no-ops instead of re-inserting
53836d2f0ba246a767ecf5f1e655a9bf56abfa3b · 2026-08-02 07:56:48 -0700 · Steve
Files touched
M src/server/broker-of-record.ts
Diff
commit 53836d2f0ba246a767ecf5f1e655a9bf56abfa3b
Author: Steve <steve@designerwallcoverings.com>
Date: Sun Aug 2 07:56:48 2026 -0700
TK-10139: fix recorder change-detection — pg returns BIGINT ids as strings; compare id fields as strings so unchanged broker/firm no-ops instead of re-inserting
---
src/server/broker-of-record.ts | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/server/broker-of-record.ts b/src/server/broker-of-record.ts
index 83d58e5..f9637fa 100644
--- a/src/server/broker-of-record.ts
+++ b/src/server/broker-of-record.ts
@@ -90,9 +90,13 @@ export async function recordBrokerOfRecord(
if (prev.rows.length) {
const p = prev.rows[0];
+ // NOTE: pg returns BIGINT columns (broker_id, firm_id) as STRINGS, while callers pass
+ // numbers — so compare id fields as strings to avoid a spurious "changed" on every run.
+ const idEq = (a: unknown, b: unknown) =>
+ (a == null ? null : String(a)) === (b == null ? null : String(b));
const same =
- (p.broker_id ?? null) === (brokerId ?? null) &&
- (p.firm_id ?? null) === (firmId ?? null) &&
+ idEq(p.broker_id, brokerId) &&
+ idEq(p.firm_id, firmId) &&
(p.broker_name ?? null) === (brokerName ?? null) &&
(p.firm_name ?? null) === (firmName ?? null);
if (same) return null; // unchanged — no-op
← e24220d TK-10139: surface Last Broker/Firm of Record — card on comme
·
back to Nationalrealestate
·
TK-10139: canonical address_key normalizer (strip trailing s 39e9dbe →