From bb67f1fc68e50f7e8d3ea2b6f07dae79ca5db93a Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Thu, 6 Jun 2024 09:02:51 -0400 Subject: [PATCH] Incorporate schema root into docID --- client/document.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/document.go b/client/document.go index ccbdfd688c..ada47cc8f9 100644 --- a/client/document.go +++ b/client/document.go @@ -777,6 +777,11 @@ func (doc *Document) GenerateDocID() (DocID, error) { return DocID{}, err } + // The DocID must take into consideration the schema root, this ensures that + // otherwise identical documents created using different schema will have different + // document IDs - we do not want cross-schema docID collisions. + bytes = append(bytes, []byte(doc.collectionDefinition.Schema.Root)...) + cid, err := ccid.NewSHA256CidV1(bytes) if err != nil { return DocID{}, err