WaseemSabir / firestore_size

Python library to calculate the approximate size of a firestore document
MIT License
2 stars 1 forks source link

Hello. It gives an exception when a document contains a document reference typed value #2

Open garawaa opened 1 year ago

garawaa commented 1 year ago

Traceback (most recent call last): File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 75, in document_size return additional_document_size + _calculate_size(document) File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 68, in _calculate_size return _object_size(obj) File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 44, in _object_size [ File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 45, in _calculate_size(key) + _calculate_size(value) File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 68, in _calculate_size return _object_size(obj) File "D:\Python39\lib\site-packages\firestore_size\calculate.py", line 31, in _object_size return 16 + sum([len(segment) + 1 for segment in obj._key._path._segments]) AttributeError: 'DocumentReference' object has no attribute '_key' This is exception message.

WaseemSabir commented 1 year ago

@garawaa can you please share what your input was?

garawaa commented 1 year ago
    docref = self.db.document(docPath)
    doc = docref.get()

    data = doc.to_dict()
    try:
        doc_size = document_size(data)
    except Exception as e:
        print(e)

When document contains a document reference value it gives an exception.