TMongoWire icon indicating copy to clipboard operation
TMongoWire copied to clipboard

toughen IBSONDocumentEnumerator against null elements

Open stijnsanders opened this issue 9 years ago • 3 comments

stijnsanders avatar Jun 13 '15 19:06 stijnsanders

Hi, Just trying out example1 and getting an 'invalid pointer error' when trying to refresh or load documents with a null field. Will you be looking at this anytime soon? Thanks

scaleman114 avatar Sep 22 '16 09:09 scaleman114

It's not strictly related to this issue, but there was indeed a bug. Please update to the recent commit.

stijnsanders avatar Sep 22 '16 17:09 stijnsanders

Then again. Having a second look, this bug may have caused me to post this issue way back then. If I try IBSONEnumerator over {{x:1},null,{x:2}} now it now fails because Can't mix documents and non-documents with IBSONDocumentEnumerator. If I were ever to make IBSONDocumentEnumerator support null elements in the array, I'd have to change:

  • stmReadBSONDocArray if l=bsonNull, but then skip the part where the object's length is read (since there's nothing there)
  • TBSONDocumentEnumerator.Next if FPos[FPosCurrent]= 0 or -1 or something invalid just to not do Load, but do a 'Reset' to at least inc(FLoadIndex) on the document or something
  • see what an array that starts with an element bsonNULL does, as it currently doesn't lead into stmReadBSONDocArray...
  • decide if it's important that {{x:1},null,{x:2}} and {{x:1},{},{x:2}} will behave exactly the same...

stijnsanders avatar Sep 22 '16 19:09 stijnsanders