fix(logging): don't overwrite a contact's NULL power with 0 on edit#245
Merged
Merged
Conversation
A contact loaded without power arrives as JSON `null`. The edit-dialog submit guard only mapped `undefined`/'' to null, so `null` fell through to `Number(null) === 0` and rewrote the column from NULL to 0 on any save. That also defeated the export's COALESCE(c.tx_pwr, s.power_watts) station-power fallback. Treat null/undefined/blank/NaN uniformly as "clear to NULL". Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a data-corruption edge case in the Edit Contact dialog where a NULL per-QSO transmit power (contacts.tx_pwr) could be unintentionally rewritten to 0 on save due to Number(null) === 0. This preserves correct semantics for “no per-QSO power recorded” and keeps ADIF export fallback behavior (COALESCE(c.tx_pwr, s.power_watts)) intact.
Changes:
- Normalize
tx_pwron submit sonull,undefined, blank, and non-numeric values are all treated as “clear toNULL”. - Prevent accidental
NULL → 0conversion when editing a contact that originally had no per-QSO power set. - Expand inline comment to document the rationale and the export impact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #244 (per-QSO transmit power). A code-review pass caught a data-corruption bug in the edit dialog that merged before the fix could be appended.
When you open an existing QSO that was logged without power,
contacts.tx_pwrisNULLand arrives in the edit dialog as JSONnull. The submit-time normalization only mappedundefinedand''tonull:nullmatched neither guard, so it fell through toNumber(null)— which is0, notnull. Saving any unrelated edit (e.g. a note) on such a QSO silently rewrote the column fromNULLto0. That also defeats the export'sCOALESCE(c.tx_pwr, s.power_watts)fallback introduced in #244: the QSO now exports0instead of the station's default power (andadifFieldomits a0, soTX_PWRvanishes from the export entirely). The empty input box hides the corruption from the operator.Fix
Treat null / undefined / blank / NaN uniformly as "clear to NULL":
== nullcatches both a cleared input and a contact loaded with no power, so a NULL power stays NULL through an edit. A real value (including0) still round-trips.Testing
npm run typecheck— cleannpm run lint— cleannpm run build— compiled successfully (verified before push)🤖 Generated with Claude Code