ParseQuery.or()没有按预期工作

时间:2014-08-14 22:40:17

标签: android parse-platform

我的代码如下所示

    ParseQuery<Request> followingsCompositeParseQuery = getFollowingsCompositeQuery();

    ParseQuery<Photo> followingsFromUserParseQuery = ParseQuery.getQuery(ParseModelNames.PHOTO );
    followingsFromUserParseQuery.whereMatchesKeyInQuery( Photo.USER_NAME, Request.FROM_USER, followingsCompositeParseQuery );

    ParseQuery<Photo> followingsToUserParseQuery = ParseQuery.getQuery( ParseModelNames.PHOTO );
    followingsToUserParseQuery.whereMatchesKeyInQuery( Photo.USER_NAME, Request.TO_USER, followingsCompositeParseQuery );

    ParseQuery<Photo> finalQuery = ParseQuery.or( Arrays.asList( followingsToUserParseQuery , followingsFromUserParseQuery));

    finalQuery.orderByDescending( "updatedAt" );
    finalQuery.findInBackground(findCallback);

我发现上面只有一个查询(followingToUserParseQuery和followingsFromUserParseQuery)被执行,而我在ParseQuery.or(...)函数中首先编写的那个是执行的查询。我不知道为什么,因为我想执行两个查询。

1 个答案:

答案 0 :(得分:1)

我认为这可能来自您将列表设置为or方法的方式,因为您的问题表明查询单独有效。

尝试使用这组线而不是您现有的线:

ParseQuery<Photo>[] photoQueries = {followingsFromUserParseQuery, followingsToUserParseQuery};
ParseQuery<Photo> finalQuery = ParseQuery.or(Arrays.asList(photoQueries));

asList()方法返回由指定数组支持的固定大小列表。通过这种方式,您可以创建一个数组并返回一个列表。