Add channel storage prop array support#908
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #908 +/- ##
===========================================
+ Coverage 97.32% 97.39% +0.06%
===========================================
Files 405 405
Lines 6540 6599 +59
Branches 858 870 +12
===========================================
+ Hits 6365 6427 +62
+ Misses 90 88 -2
+ Partials 85 84 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR Review: Add channel storage prop array supportMajor Issueflatten() returns inconsistent format for single-element array props In src/entities/game-channel-storage-prop.ts, the early-return optimisation for single props breaks array key semantics: When an array key (e.g. items[]) has exactly one row, flatten returns value as a plain string. With two or more rows it returns value as a JSON-encoded array string. Clients using JSON.parse(prop.value) on array-keyed props will get inconsistent types depending on how many elements are stored. The fix is to branch on isArrayKey rather than props.length: // before: if (props.length === 1) return props[0].toJSON()
if (props.length === 1 && !isArrayKey(props[0].key)) return props[0].toJSON()
const sorted = [...props].sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())
const representative = sorted[0].toJSON()
representative.value = JSON.stringify(sorted.map((p) => p.value))
return representativeNo existing test covers single-element array retrieval in get-storage or list-storage. Minor IssueprocessArrays - createdBy sort mutates local array in-place In put-storage.ts, existingForKey.sort(...) mutates the array that the deletion loop below also iterates. Using [...existingForKey].sort(...) avoids an implicit order dependency (harmless now but fragile). No issues found in: performance, security, or overall test coverage. |
2c8ae8f to
9c4a717
Compare
|
Overall this is a well-structured PR with good test coverage. A couple of things worth addressing. |
PR Review: Add channel storage prop array supportOverall this is a well-structured PR with good test coverage. A few concrete issues worth addressing: Potential Bugs
Previously the cache write was gated on Minor Issues
Array items created in the same transaction (e.g. via a single PUT with multiple
|
9c4a717 to
7286ab8
Compare
7286ab8 to
a3f083a
Compare
No description provided.