File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed
Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ const ignoredRe = [
4343] ;
4444
4545/** If non-empty, list the test cases to run exclusively. */
46- const exclusiveRe = [ ] ;
46+ const exclusiveRe = [
47+ / s e t : M e r g e A l l c a n n o t b e s p e c i f i e d w i t h e m p t y d a t a ./ , // b/73495873
48+ ] ;
4749
4850const docRef = function ( path ) {
4951 const relativePath = ResourcePath . fromSlashSeparatedString ( path ) . relativeName ;
Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ class WriteBatch {
280280
281281 validate . isDocumentReference ( 'documentRef' , documentRef ) ;
282282 validate . isDocument ( 'data' , data , {
283- allowEmpty : ! merge ,
283+ allowEmpty : true ,
284284 allowDeletes : merge ? 'all' : 'none' ,
285285 allowServerTimestamps : true ,
286286 } ) ;
@@ -292,11 +292,13 @@ class WriteBatch {
292292 const transform = DocumentTransform . fromObject ( documentRef , data ) ;
293293 const documentMask = DocumentMask . fromObject ( data ) ;
294294
295+ const hasDocumentData = ! document . isEmpty || ! documentMask . isEmpty ;
296+
295297 let write ;
296298
297299 if ( ! merge ) {
298300 write = document . toProto ( ) ;
299- } else if ( ! document . isEmpty || ! documentMask . isEmpty ) {
301+ } else if ( hasDocumentData || transform . isEmpty ) {
300302 write = document . toProto ( ) ;
301303 write . updateMask = documentMask . toProto ( ) ;
302304 }
Original file line number Diff line number Diff line change @@ -979,6 +979,15 @@ describe('set document', function() {
979979 ) ;
980980 } ) ;
981981
982+ it ( 'supports empty merge' , function ( ) {
983+ firestore . api . Firestore . _commit = function ( request , options , callback ) {
984+ requestEquals ( request , set ( document ( ) , updateMask ( ) ) ) ;
985+ callback ( null , writeResult ( 1 ) ) ;
986+ } ;
987+
988+ return firestore . doc ( 'collectionId/documentId' ) . set ( { } , { merge : true } ) ;
989+ } ) ;
990+
982991 it ( 'supports nested empty merge' , function ( ) {
983992 firestore . api . Firestore . _commit = function ( request , options , callback ) {
984993 requestEquals (
@@ -1030,12 +1039,6 @@ describe('set document', function() {
10301039 } , / F i e l d V a l u e .d e l e t e \( \) m u s t a p p e a r a t t h e t o p - l e v e l a n d c a n o n l y b e u s e d i n u p d a t e \( \) o r s e t \( \) w i t h { merge:t r u e } ./ ) ;
10311040 } ) ;
10321041
1033- it ( 'rejects empty merges' , function ( ) {
1034- assert . throws ( ( ) => {
1035- firestore . doc ( 'collectionId/documentId' ) . set ( { } , { merge : true } ) ;
1036- } , / A t l e a s t o n e f i e l d m u s t b e u p d a t e d ./ ) ;
1037- } ) ;
1038-
10391042 it ( "doesn't accept arrays" , function ( ) {
10401043 assert . throws ( ( ) => {
10411044 firestore . doc ( 'collectionId/documentId' ) . set ( [ 42 ] ) ;
You can’t perform that action at this time.
0 commit comments