我有一个连接表,其中包含from列和a列.两列都指向用户对象.执行此OR查询时,它会抛出错误:’OR查询不支持包含’的子查询’
有没有办法解决?谢谢!
PFQuery *userIsFriendSender = [PFQuery queryWithClassName:@"UserRelationships"]; [userIsFriendSender whereKey:@"from" equalTo:[PFUser currentUser]]; [userIsFriendSender whereKey:@"active" equalTo:@YES]; [userIsFriendSender includeKey:@"to"]; // set up query to get all relationships where a use friended the current user PFQuery *userIsFriendReceiver = [PFQuery queryWithClassName:@"UserRelationships"]; [userIsFriendReceiver whereKey:@"to" equalTo:[PFUser currentUser]]; [userIsFriendReceiver whereKey:@"active" equalTo:@YES]; [userIsFriendReceiver includeKey:@"from"]; PFQuery *query = [PFQuery orQueryWithSubqueries:@[userIsFriendSender,userIsFriendReceiver]];
解决方法
尝试将includeKey:子句移动到联合查询.
PFQuery *query = [PFQuery orQueryWithSubqueries:@[userIsFriendSender,userIsFriendReceiver]]; [query includeKey:@"from"]; [query includeKey:@"to"];