1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00
unleash.unleash/src
Thomas Heartman e125c0f072
fix(1-3928): prevent overwriting existing values in instance store (#10360)
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.
2025-07-16 12:10:15 +00:00
..
lib fix(1-3928): prevent overwriting existing values in instance store (#10360) 2025-07-16 12:10:15 +00:00
mailtemplates fix: health-technical debt trends in emails (#10308) 2025-07-04 16:46:59 +02:00
migrations chore: amend user-created-missing events (#10333) 2025-07-09 07:19:25 +00:00
test fix(1-3928): prevent overwriting existing values in instance store (#10360) 2025-07-16 12:10:15 +00:00
migrator.ts feat: do not lock until migrations are needed (#10170) 2025-06-18 17:40:21 +02:00
server-dev.ts chore: Add PAYG trial events flag to Unleash (#10336) 2025-07-09 14:56:01 +01:00
server.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
test-setup.ts task: migrate tests to vitest 2025-05-16 11:19:10 +02:00