Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

Convert strings passed for an in query on a DocumentID to DocumentRefs for ease of use #421

Closed

Description

@crwilcox

When querying a collection with an in filter on a documentId, passing an array of strings will not work, instead returning an error

Repro:

from google.cloud import firestore

client = firestore.Client("your-project-id")
collection = client.collection('0')

query = collection.where("__name__", "in", ["hello", "world"])
[i for i in query.stream()]

Node.js handles this today by validating the reference and as part of it doing a conversion. It would be convenient for go users if a similar conversion were done.
Referenced Node Code: https://github.com/googleapis/nodejs-firestore/blob/9a1a9dcd56dc125159be3ce7356a6ebce04519a9/dev/src/reference.ts#L1646

This code works today, so this is a matter of detecting the type mismatch with DocumentID queries and adjusting it on the user's behalf.

from google.cloud import firestore

client = firestore.Client("crwilcox-firestore")
collection = client.collection('0')

docRefs = [
    collection.document("hello"),
    collection.document("world")
]
query = collection.where("__name__", "in", docRefs)
[i for i in query.stream()]

Related Go Issue: googleapis/google-cloud-go#4151

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 13, 2021
  2. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Nov 11, 2021
  3. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Nov 18, 2021
  4. added 3 commits that reference this issue on Nov 18, 2021
    7d5f732
    fa450c5
    efd509d
  5. self-assigned this
    on Dec 1, 2021
  6. added a commit that references this issue on Dec 7, 2021
    51d820a
  7. added a commit that references this issue on Dec 22, 2021
    a66c097
  8. added a commit that references this issue on Dec 23, 2021
    7d71244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the googleapis/python-firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions