firebase-admin-python icon indicating copy to clipboard operation
firebase-admin-python copied to clipboard

Add pipeline snippets for Firestore

Open morganchen12 opened this issue 2 months ago • 2 comments

morganchen12 avatar Nov 04 '25 23:11 morganchen12

After adding the snippets for expressions and inputs, I'm getting these errors:

(.venv) morganchen-mac:firebase-admin-python morganchen$ ./lint.sh 
Running linter on snippets/firestore/firestore_pipelines.py
************* Module snippets.firestore.firestore_pipelines
snippets/firestore/firestore_pipelines.py:1770:20: E1101: Module 'firebase_admin.firestore' has no 'SERVER_TIMESTAMP' member (no-member)
snippets/firestore/firestore_pipelines.py:2009:41: E1101: Class 'Expression' has no 'array' member (no-member)
snippets/firestore/firestore_pipelines.py:2010:16: E1101: Class 'Expression' has no 'array' member (no-member)
snippets/firestore/firestore_pipelines.py:2288:12: E1101: Instance of 'Field' has no 'array_get' member (no-member)

For the errors:

  1. I'm not sure why I'm getting this error, it seems to be invoked correctly based on our docs
  2. I'm also not sure why I'm getting this error since Array is documented here
  3. See 2
  4. The array_get method seems to just be missing from the Python SDK. @daniel-sanche this is likely me not reading something somewhere, but just in case it was overlooked

morganchen12 avatar Nov 11 '25 04:11 morganchen12

  1. One of those is from google.cloud import firestore, and the other is from firebase_admin import firestore. I'm not super familiar with the firebase_admin wrapper, but I don't think those are fully equivalent

  2. In the end, I think Array was actually implemented as a stand-alone class:

from google.cloud.firestore_v1.pipeline_expressions import Array
Array(["bar", Field.of("baz")])

It looks like there's an out-dated docstring. I can fix that.

Let me know if you think it's important to have array exposed on Expression as well though. I removed it in an effort to keep the API surface manageable, instead of exposing multiple ways of expressing the same thing. But I can add it back if that's more consistent with other languages.

  1. array_get was a late addition, but it should be in the preview branch as of yesterday. Maybe try running again

daniel-sanche avatar Nov 11 '25 22:11 daniel-sanche