2
2
// hungry/js/test/parse_query_test.js
3
3
//
4
4
// Some new tests are added.
5
+ 'use strict' ;
6
+
7
+ const Parse = require ( 'parse/node' ) ;
5
8
6
9
describe ( 'Parse.Query testing' , ( ) => {
7
10
it ( "basic query" , function ( done ) {
@@ -1574,6 +1577,29 @@ describe('Parse.Query testing', () => {
1574
1577
} ) ;
1575
1578
} ) ;
1576
1579
1580
+ it ( "dontSelect query without conditions" , function ( done ) {
1581
+ const RestaurantObject = Parse . Object . extend ( "Restaurant" ) ;
1582
+ const PersonObject = Parse . Object . extend ( "Person" ) ;
1583
+ const objects = [
1584
+ new RestaurantObject ( { location : "Djibouti" } ) ,
1585
+ new RestaurantObject ( { location : "Ouagadougou" } ) ,
1586
+ new PersonObject ( { name : "Bob" , hometown : "Djibouti" } ) ,
1587
+ new PersonObject ( { name : "Tom" , hometown : "Yoloblahblahblah" } ) ,
1588
+ new PersonObject ( { name : "Billy" , hometown : "Ouagadougou" } )
1589
+ ] ;
1590
+
1591
+ Parse . Object . saveAll ( objects , function ( ) {
1592
+ const query = new Parse . Query ( RestaurantObject ) ;
1593
+ const mainQuery = new Parse . Query ( PersonObject ) ;
1594
+ mainQuery . doesNotMatchKeyInQuery ( "hometown" , "location" , query ) ;
1595
+ mainQuery . find ( ) . then ( results => {
1596
+ equal ( results . length , 1 ) ;
1597
+ equal ( results [ 0 ] . get ( 'name' ) , 'Tom' ) ;
1598
+ done ( ) ;
1599
+ } ) ;
1600
+ } ) ;
1601
+ } ) ;
1602
+
1577
1603
it ( "object with length" , function ( done ) {
1578
1604
var TestObject = Parse . Object . extend ( "TestObject" ) ;
1579
1605
var obj = new TestObject ( ) ;
@@ -2088,7 +2114,7 @@ describe('Parse.Query testing', () => {
2088
2114
console . log ( error ) ;
2089
2115
} ) ;
2090
2116
} ) ;
2091
-
2117
+
2092
2118
// #371
2093
2119
it ( 'should properly interpret a query' , ( done ) => {
2094
2120
var query = new Parse . Query ( "C1" ) ;
@@ -2104,30 +2130,30 @@ describe('Parse.Query testing', () => {
2104
2130
done ( ) ;
2105
2131
} )
2106
2132
} ) ;
2107
-
2133
+
2108
2134
it ( 'should properly interpret a query' , ( done ) => {
2109
2135
var user = new Parse . User ( ) ;
2110
2136
user . set ( "username" , "foo" ) ;
2111
2137
user . set ( "password" , "bar" ) ;
2112
2138
return user . save ( ) . then ( ( user ) => {
2113
2139
var objIdQuery = new Parse . Query ( "_User" ) . equalTo ( "objectId" , user . id ) ;
2114
2140
var blockedUserQuery = user . relation ( "blockedUsers" ) . query ( ) ;
2115
-
2141
+
2116
2142
var aResponseQuery = new Parse . Query ( "MatchRelationshipActivityResponse" ) ;
2117
2143
aResponseQuery . equalTo ( "userA" , user ) ;
2118
2144
aResponseQuery . equalTo ( "userAResponse" , 1 ) ;
2119
-
2145
+
2120
2146
var bResponseQuery = new Parse . Query ( "MatchRelationshipActivityResponse" ) ;
2121
2147
bResponseQuery . equalTo ( "userB" , user ) ;
2122
2148
bResponseQuery . equalTo ( "userBResponse" , 1 ) ;
2123
-
2149
+
2124
2150
var matchOr = Parse . Query . or ( aResponseQuery , bResponseQuery ) ;
2125
2151
var matchRelationshipA = new Parse . Query ( "_User" ) ;
2126
2152
matchRelationshipA . matchesKeyInQuery ( "objectId" , "userAObjectId" , matchOr ) ;
2127
2153
var matchRelationshipB = new Parse . Query ( "_User" ) ;
2128
2154
matchRelationshipB . matchesKeyInQuery ( "objectId" , "userBObjectId" , matchOr ) ;
2129
-
2130
-
2155
+
2156
+
2131
2157
var orQuery = Parse . Query . or ( objIdQuery , blockedUserQuery , matchRelationshipA , matchRelationshipB ) ;
2132
2158
var query = new Parse . Query ( "_User" ) ;
2133
2159
query . doesNotMatchQuery ( "objectId" , orQuery ) ;
@@ -2140,8 +2166,8 @@ describe('Parse.Query testing', () => {
2140
2166
fail ( "should not fail" ) ;
2141
2167
done ( ) ;
2142
2168
} ) ;
2143
-
2144
-
2169
+
2170
+
2145
2171
} ) ;
2146
-
2172
+
2147
2173
} ) ;
0 commit comments