Changes:
- Fixed how database path built from url, in more cross-platform way, to fix issue experienced under local development under Windows
- made log muting more testable and get console log muting tests working.
kote-isaev/jsdb:main into main
Changes:
Added fix for assigning property to null and undefined.
Null work as expexted (property assigned to null and saved), assign to undefined works as delete property.
@kote-isaev Thanks again for this, Kote.
I’ve cherry-picked the Windows fix (I’d missed it in the tests – it’s an issue I’d previously raised with the Node folks @ https://github.com/nodejs/node/issues/37845 – thank you for catching this) and the null/undefined implementations.
For undefined, I went ahead and made it so that instead of deleting the record, it actually stores undefined. This is so that it behaves the same regardless of whether you’re setting undefined in an object when creating it or later.
So:
db.myTable.myObject = { a: undefined }
And
db.myTable.myObject = {}
db.myTable.myObject.a = undefined
Now produce the same result;
{ a: undefined }
Other than that, I wasn’t sure what the console.log changes improved regarding the unit tests so I’ve left them out for now. If there is a limitation I’m missing with those tests that your code improves, would you mind detailing it in an issue and I’ll reconsider.
Thanks again for contributing and helping make JSDB better; I really appreciate it :)
💕
The contents of this pull request have now been published in JSDB version 3.0.4.
Thanks again, @kote-isaev :)
Thanks for quick response and accepting my pull request.
Lets see how this update about undefined will settle. From JSDB point of view it is correct (to keep behavior of assignment consistent).
My motivation for deleting property instead was the fact that undefined values are being skipped during JSON serialization that happens e. g. during sending a JSDB record as part of response body, or if that record will be JSON-ed as part of "JSON cloning" of record.
For that it is better to use structuralClone if it available, but it seems I was a bit over-engineering this aspect, may be.
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?