-
Notifications
You must be signed in to change notification settings - Fork 976
Description
Operating System
Ubuntu 22.04.4 LTS
Browser Version
Chrome Version 121.0.6167.160 (Official Build) (64-bit)
Firebase SDK Version
10.7.2
Firebase SDK Product:
Auth, Firestore
Describe your project's tooling
Angular 16.2.9. Firestore is running within a web worker.
Describe the problem
When firestore caching is active, equality query's for Time Stamp fields do not return expected results. I have a set of documents sharing a common TimeStamp of exactly 2024-02-20 . When I query with caching disabled, I correctly get back results. When caching is enabled, no results are returned.
Steps and code to reproduce issue
const app = initializeApp(data.config);
db = initializeFirestore(app, { ignoreUndefinedProperties: true, localCache: persistentLocalCache(/settings/{tabManager: persistentSingleTabManager({forceOwnership:true})},), });
Below Fails (returns 0 documents w/ metaData from cache: true, never returns again):
const coll = collection(db, "/service-providers/aKgDbsxAm0iCTnZR53cp/resourceDayAddressRouting");
const que = query(coll,...[where("resourceDay","==",startOfDay(new Date(2024,1,20)))]);
onSnapshot(que, (querySnapshot) => {
const metaData = querySnapshot.metadata;
const docs = [];
querySnapshot.forEach((doc) => {
const docData = doc.data();
docs.push(docData);
});
console.log(docs);
);
But if you change query to look for :
const que = query(coll,...[where("resourceDay",">=",startOfDay(new Date(2024,1,20))),
where("resourceDay","<",addSeconds(startOfDay(new Date(2024,1,20)),1))]);
All 60 rows come back, with the identical timestamp value for resource day specified when querying for equality. (seconds and nanoseconds).
Timestamp(seconds=1708405200, nanoseconds=0)
If you initialize firestore without caching i.e. : db = initializeFirestore(app, { ignoreUndefinedProperties: true });
Then you also get the full 60 rows when checking for exact equality
const que = query(coll,...[where("resourceDay","==",startOfDay(new Date(2024,1,20)))]);