TeiaLabs / redb

1 stars 0 forks source link

Allow choosing the (possibly overriden) Document.get_hash as the default _id #16

Closed cardoso-neto closed 1 year ago

cardoso-neto commented 1 year ago
  1. Updates on any attribute in Document.hashing_fields should raise an error.
  2. There should be test coverage of this behavior.
joaovbsevero commented 1 year ago
  1. Updates on any attribute in Document.hashing_fields should raise an error.
  2. There should be test coverage of this behavior.

What is the relation between this and the title?

cardoso-neto commented 1 year ago

Currently the default _id of a document is an object id, which is essentially random. I'd like users to be able to use the result of get_hash as the _id by default. This would have to be done on an override of the .dict() method (similar to what you had done before for the the hash attr, but for the _id attr).

However, if a user updates one of the hashable_fields while using get_hash() for _ids, the _id will no longer match the contents of the document, therefore users should be prevented from shooting themselves in the foot in this manner.

joaovbsevero commented 1 year ago

Adressed on: https://github.com/TeiaLabs/redb/commit/97266f75afcc6c6c35acb2a3eda34ed4b99fbf8c

joaovbsevero commented 1 year ago

Fixed on the last refactoring