marioreggiori / objectdb

Persistent embedded document-oriented NoSQL database for Dart and Flutter.
https://pub.dev/packages/objectdb
MIT License
190 stars 21 forks source link

null should be a valid type for _decode #40

Closed fhuonder closed 4 years ago

fhuonder commented 4 years ago

Hi,

The db behaves wrong when a update-record contains null values. Inserting and updating documents with null-values works because because the default function json.encode is used.

This leads to the problem, when calling open() it always returns the inital version (and not the latest (upated) one). This because on open() the database goes through all lines in the db-file and the insert-lines ('+') are decoded by json.decode but the update-lines ('~') are decoded by the custom function _decode and this custom decode-function does not accept null values. In this case an ObjectDBException is thrown and this leads to the line being ignored.

In my opinion two things should be done:

Regards, Florian

marioreggiori commented 4 years ago

Hello @fhuonder, thank you for contributing! I've updated the execution_queue-lib as requested https://github.com/marioreggiori/execution_queue/commit/55b8548c78f0cb333664ef79f76e030ac101d944 and merged your pull request https://github.com/marioreggiori/objectdb/pull/41. Tests run without any errors. The new version is available at pub https://pub.dev/packages/objectdb/versions/1.0.10