-
Notifications
You must be signed in to change notification settings - Fork 991
Description
Operating System
macOS
Browser Version
Safari 16.5.2
Firebase SDK Version
10.5.0
Firebase SDK Product:
Firestore
Describe your project's tooling
index.html with source tag. Just javascript.
Describe the problem
The queryEqual method doesn't seem to work for all cases. It is my understanding that it should return true if both queries return the same set of documents. I will give you an example where it returns false even though the document set is the same.
Steps and code to reproduce issue
Use the example data.
var q3 = query(collection(db, "cities"), or(where("capital", "==", true), where("capital", "==", false)));
var q4 = collection(db, "cities");
const querySnapshot = await getDocs(q3);
querySnapshot.forEach(doc => console.log(doc.id, " => ", doc.data()));
const querySnapshot2 = await getDocs(q3);
querySnapshot.forEach(doc => console.log(doc.id, " => ", doc.data()));
console.log(queryEqual(q3, q4));
Both queries return the same document set, and it's guaranteed that q3 will always return the same set as q4, yet queryEqual returns false.
Even something much more simple and obvious returns false
var q3 = query(collection(db, "cities"), or(where("capital", "==", true), where("capital", "==", false)));
var q4 = query(collection(db, "cities"), or(where("capital", "==", false), where("capital", "==", true)));
console.log(queryEqual(q3, q4));
From further tests, it seems that queryEqual only returns true if both queries are written exactly the same way, not if the result would turn out the same. Is this by design? In that case, what is the use case of queryEqual? It seems pointless to me.