mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02: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. |
||
---|---|---|
.. | ||
lib | ||
mailtemplates | ||
migrations | ||
test | ||
migrator.ts | ||
server-dev.ts | ||
server.ts | ||
test-setup.ts |