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

Issue with documentId() in conjunction with an or filter #8049

Open
ArthurDias01 opened this issue Mar 1, 2024 · 3 comments
Open

Issue with documentId() in conjunction with an or filter #8049

ArthurDias01 opened this issue Mar 1, 2024 · 3 comments

Comments

@ArthurDias01
Copy link

ArthurDias01 commented Mar 1, 2024

Operating System

windows 11

Browser Version

Windows 11 Pro 23H2 22631.3155

Firebase SDK Version

9.21.0

Firebase SDK Product:

Firestore

Describe your project's tooling

We are using firebase alongside expo to create an all platform app.

"@react-native-firebase/analytics": "^18.2.0",
"@react-native-firebase/app": "^18.2.0",
"@react-native-firebase/app-check": "^18.2.0",
"@react-native-firebase/auth": "^18.2.0",
"firebase": "^9.21.0",

Describe the problem

We were tring to accomplish a composite query that would fetch documents by Id or other property. The problem is whenever we try to use the documentId() method, the app throws an error saying we can't use that query because we need to create an index.

image

then when we follow the link to create the query we face a firebase error:

image

so we can't really query by id or another document field.

Because changing it to this works no problem and doesn't request you to create an index

.where(Filter.or(Filter.where('field1', '==', 'value'), Filter.where('field2', '==', 'value')))

Steps and code to reproduce issue

minimal reproducible code:

import { firestore } from 'firebase-admin'
import FieldPath = firestore.FieldPath
import Filter = firestore.Filter

const db = firestore()

export async function run(db: FirebaseFirestore.Firestore) {
  
  db.collection('farms')
    .where(Filter.or(Filter.where(FieldPath.documentId(), '==', 'value'), Filter.where('field2', '==', 'value')))
    .get()
    .then((snapshot) => {
      console.log(snapshot)
    })
}
@ArthurDias01 ArthurDias01 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Mar 1, 2024
@argzdev argzdev removed the new A new issue that hasn't be categoirzed as question, bug or feature request label Mar 1, 2024
@cherylEnkidu cherylEnkidu self-assigned this Mar 3, 2024
@cherylEnkidu
Copy link
Contributor

Hi @ArthurDias01 ,

Thank you for filling up this ticket! The bug has been verified (internal tracking ticket: b/328297935)
I will update this ticket when bug is fixed.

@khevamann
Copy link

Any update on this one?

@atsjo
Copy link

atsjo commented Sep 28, 2024

Any updates on this? I just ran into the same problem trying to combine a 'in' query on documentId with another field query via OR in firebase-admin 12.5.0...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants