File tree 3 files changed +34
-4
lines changed
3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -967,8 +967,11 @@ export class QueryDocumentSnapshot<T = PublicDocumentData>
967
967
export class Query < T = PublicDocumentData >
968
968
extends Compat < ExpQuery < T > >
969
969
implements PublicQuery < T > {
970
+ private readonly _userDataWriter : UserDataWriter ;
971
+
970
972
constructor ( readonly firestore : Firestore , delegate : ExpQuery < T > ) {
971
973
super ( delegate ) ;
974
+ this . _userDataWriter = new UserDataWriter ( firestore ) ;
972
975
}
973
976
974
977
where (
@@ -1076,7 +1079,18 @@ export class Query<T = PublicDocumentData>
1076
1079
} else {
1077
1080
query = getDocs ( this . _delegate ) ;
1078
1081
}
1079
- return query . then ( result => new QuerySnapshot ( this . firestore , result ) ) ;
1082
+ return query . then (
1083
+ result =>
1084
+ new QuerySnapshot (
1085
+ this . firestore ,
1086
+ new ExpQuerySnapshot < T > (
1087
+ this . firestore . _delegate ,
1088
+ this . _userDataWriter ,
1089
+ this . _delegate ,
1090
+ result . _snapshot
1091
+ )
1092
+ )
1093
+ ) ;
1080
1094
}
1081
1095
1082
1096
onSnapshot ( observer : PartialObserver < PublicQuerySnapshot < T > > ) : Unsubscribe ;
Original file line number Diff line number Diff line change @@ -32,12 +32,18 @@ apiDescribe('Firestore', (persistence: boolean) => {
32
32
db : firestore . FirebaseFirestore ,
33
33
data : { }
34
34
) : Promise < void > {
35
- const doc = db . collection ( 'rooms' ) . doc ( ) ;
35
+ const collection = db . collection ( db . collection ( 'a' ) . doc ( ) . id ) ;
36
+ const doc = collection . doc ( ) ;
36
37
return doc
37
38
. set ( data )
38
39
. then ( ( ) => doc . get ( ) )
39
- . then ( snapshot => {
40
- expect ( snapshot . data ( ) ) . to . deep . equal ( data ) ;
40
+ . then ( docSnapshot => {
41
+ expect ( docSnapshot . data ( ) ) . to . deep . equal ( data ) ;
42
+ return collection . get ( ) ;
43
+ } )
44
+ . then ( querySnapshot => {
45
+ const [ docSnapshot ] = querySnapshot . docs ;
46
+ expect ( docSnapshot . data ( ) ) . to . deep . equal ( data ) ;
41
47
} ) ;
42
48
}
43
49
Original file line number Diff line number Diff line change 16
16
*/
17
17
18
18
import { use } from 'chai' ;
19
+ import { Indexable } from '../../src/util/misc' ;
19
20
20
21
/**
21
22
* Duck-typed interface for objects that have an isEqual() method.
@@ -57,6 +58,15 @@ function customDeepEqual(
57
58
return customMatcher . equalsFn ( left , right ) ;
58
59
}
59
60
}
61
+ if ( left && typeof left === 'object' && right && typeof right === 'object' ) {
62
+ // The `isEqual` check below returns true if firestore-exp types are
63
+ // compared with API types from Firestore classic. We do want to
64
+ // differentiate between these types in our tests to ensure that the we do
65
+ // not return firestore-exp types in the classic SDK.
66
+ if ( ( left as Indexable ) . constructor !== ( right as Indexable ) . constructor ) {
67
+ return false ;
68
+ }
69
+ }
60
70
if ( typeof left === 'object' && left && 'isEqual' in left ) {
61
71
return ( left as Equatable < unknown > ) . isEqual ( right ) ;
62
72
}
You can’t perform that action at this time.
0 commit comments