mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-24 20:06:55 +01:00
Fixes a bug in the instance store where insert and bulkUpsert would overwrite existing properties if there was a row there already. Now it'll ignore any properties that are undefined. The implementation is lifted directly from `src/lib/db/client-applications-store.ts` (line 107 atm). Additionally, I've renamed the `insert` method to `upsert` to make it clearer what it does (and because we already have `bulkUpsert`). The method seems to only be used in tests, anyway. I do not anticipate any changes to be required in enterprise (I've checked). ## Discussion points: This implementation uses `delete` to remove properties from the object. Why didn't I do it some other way? Two main reasons: 1. We've had this implementation for 4 years in the client applications store. If there were serious issues with it, we'd probably know by know. (Probably.) 2. The only way I can think of without deleting, would be to use `Object.fromEntries` and `Object.toEntries` and either map or reduce. That'll double the amount of property iterations we'll need to do. So naively, this strikes me as being more efficient. If you know better solutions, I will of course be happy to take them. If not, I'd like to leave this as is and then change it if we see that it's causing issues. |
||
|---|---|---|
| .. | ||
| __snapshots__ | ||
| addons | ||
| db | ||
| domain/project-health | ||
| error | ||
| events | ||
| features | ||
| interfaces | ||
| middleware | ||
| openapi | ||
| routes | ||
| schema | ||
| services | ||
| tags | ||
| types | ||
| users | ||
| util | ||
| app.test.ts | ||
| app.ts | ||
| create-config.test.ts | ||
| create-config.ts | ||
| default-custom-auth-deny-all.ts | ||
| internals.ts | ||
| logger.test.ts | ||
| logger.ts | ||
| metric-events.ts | ||
| metrics-gauge.test.ts | ||
| metrics-gauge.ts | ||
| metrics.test.ts | ||
| metrics.ts | ||
| server-impl.test.ts | ||
| server-impl.ts | ||