Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk_writer default assignment not working in Client.recursive_delete #564

Closed
didi-rf opened this issue Apr 12, 2022 · 1 comment · Fixed by #565
Closed

bulk_writer default assignment not working in Client.recursive_delete #564

didi-rf opened this issue Apr 12, 2022 · 1 comment · Fixed by #565
Labels
api: firestore Issues related to the googleapis/python-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@didi-rf
Copy link
Contributor

didi-rf commented Apr 12, 2022

Environment details

  • OS type and version: macOS Big Sur, version 11.6.4
  • Python version: Python 3.9.9
  • pip version: pip 21.3.1
  • google-cloud-firestore version: google-cloud-firestore==2.4.0

Steps to reproduce

  1. call Client.recursive_delete with bulk_writer=None (default value)

Code example

    from google.cloud import firestore
    db = firestore.Client('myProject')
    coll = db.collection("a", "b", "c")
    coll.add({"e": "e"},"d")
    db.recursive_delete(coll)

Stack trace

Traceback (most recent call last):
  File "/Users/didi/git/test.py", line 28, in <module>
    test()
  File "/Users/didi/git/test.py", line 25, in test
    db.recursive_delete(coll)
  File "/Users/didi/.virtualenvs/test/lib/python3.9/site-packages/google/cloud/firestore_v1/client.py", line 324, in recursive_delete
    return self._recursive_delete(reference, bulk_writer, chunk_size=chunk_size,)
  File "/Users/didi/.virtualenvs/test/lib/python3.9/site-packages/google/cloud/firestore_v1/client.py", line 348, in _recursive_delete
    bulk_writer.delete(doc_snap.reference)
AttributeError: 'NoneType' object has no attribute 'delete'

Work around

    from google.cloud import firestore
    db = firestore.Client('myProject')
    coll = db.collection("a", "b", "c")
    coll.add({"e": "e"},"d")
    db.recursive_delete(coll, bulk_writer=db.bulk_writer())
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Apr 12, 2022
@didi-rf
Copy link
Contributor Author

didi-rf commented Apr 12, 2022

Here is a PR that should fix this issue: #565
Thanks!

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 13, 2022
@meredithslota meredithslota added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants