This repository was archived by the owner on Jan 26, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,18 @@ function validateColumn(column: string) {
6565}
6666
6767function validateFields ( data ) {
68+ // Check for multiple GeoPoints.
69+ var geoPointCount = 0 ;
70+ for ( var prop in data ) {
71+ if ( data . hasOwnProperty ( prop ) &&
72+ ( data [ prop ] instanceof Parse . GeoPoint ) ) {
73+ ++ geoPointCount ;
74+ if ( geoPointCount > 1 ) {
75+ throw Error ( 'There can only be 1 GeoPoint when mutating an object.' ) ;
76+ }
77+ }
78+ }
79+
6880 if ( data . hasOwnProperty ( 'objectId' ) ) {
6981 warning ( 'Ignoring reserved field: objectId' ) ;
7082 delete data . objectId ;
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ describe('Mutation Generators', function() {
4848 expect ( result instanceof Parse . Promise ) . toBe ( true ) ;
4949 } ) ;
5050
51+ it ( "fails to generate a Set Mutation with multiple GeoPoints" , function ( ) {
52+ expect ( function ( ) {
53+ var id = new Id ( 'Klass' , '01' ) ;
54+ Mutation . Set ( id , {
55+ g1 : new Parse . GeoPoint ( ) ,
56+ g2 : new Parse . GeoPoint ( ) ,
57+ } ) ;
58+ } ) . toThrow ( 'There can only be 1 GeoPoint when mutating an object.' ) ;
59+ } ) ;
60+
5161 it ( 'generates an Unset Mutation' , function ( ) {
5262 var id = new Id ( 'Klass' , 'O1' ) ;
5363 var m = Mutation . Unset ( id , 'no_more' ) ;
You can’t perform that action at this time.
0 commit comments