mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
fix: legacy UUID treatments findable via $or fallback (#6923)
updateIdQuery() and upsertQueryFor() now use
{$or: [{identifier: UUID}, {_id: UUID}]}
instead of only {identifier: UUID}. This matches both:
- New documents (UUID in identifier field, ObjectId in _id)
- Legacy documents (UUID directly in _id, no identifier field)
Gated behind env.uuidHandling (UUID_HANDLING env var, default true).
All 30 treatment tests pass:
- 3 legacy UUID tests (issue-6923): DELETE, PUT, GET all work
- 12 gap-treat-012 tests: new data paths unaffected
- 15 uuid-handling tests: edge cases, UUID_HANDLING=false still works
Fixes #6923 (unable to edit/save/delete overrides for legacy data)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Legacy UUID Data Test: Issue #6923 Reproduction
|
||||
* Legacy UUID Data Test: Issue #6923 Regression
|
||||
*
|
||||
* ISSUE: https://github.com/nightscout/cgm-remote-monitor/issues/6923
|
||||
*
|
||||
@@ -11,10 +11,11 @@
|
||||
*
|
||||
* The test inserts a legacy-shaped document directly into MongoDB
|
||||
* (bypassing normalizeTreatmentId) and then exercises the API
|
||||
* DELETE and PUT paths that a user would trigger from Reports > Treatments.
|
||||
* DELETE, PUT, and GET paths that a user would trigger from Reports > Treatments.
|
||||
*
|
||||
* EXPECTED RESULT: These tests FAIL, proving the legacy data bug.
|
||||
* When all tests pass, the bug is fixed.
|
||||
* FIX: updateIdQuery() and upsertQueryFor() now use $or to match both
|
||||
* {identifier: UUID} (new docs) and {_id: UUID} (legacy docs).
|
||||
* All 3 tests pass, confirming Loop can manage pre-existing overrides.
|
||||
*/
|
||||
|
||||
const request = require('supertest');
|
||||
|
||||
Reference in New Issue
Block a user