ParseQuery即使成功寄希望于从本地数据存储,查询时给出0对象 [英] ParseQuery gives 0 objects when querying from local datastore even after successfully pinning

查看:204
本文介绍了ParseQuery即使成功寄希望于从本地数据存储,查询时给出0对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用parse.com的Andr​​oid SDK和在一个特殊的问题已经到了。

I am using the Android SDK of parse.com and have arrived at a peculiar problem.

从片段的onCreate:

From a fragment's onCreate:


  1. 从服务器获取的对象。

  2. 针吧。

  3. 获取来自本地数据存储的对象。

下面是从的onCreate的code的一个片段:

Here is a snippet of the code from the onCreate:

ParseObject myChatGroup = ParseObject.createWithoutData("ChatGroup", "mOJGWRiLPC");
    myChatGroup.fetchInBackground(new GetCallback<ParseObject>() {
        @Override
        public void done(ParseObject chatGroup1, ParseException e) {
            if (e == null) {
                l.d("Fetched chat group: " + chatGroup1 + " from server");
                chatGroup1.pinInBackground(new SaveCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e == null) {
                            l.d("Successfully pinned chat group");
                            ParseQuery<ParseObject> chatGroupParseQuery = new ParseQuery<>("ChatGroup");
                            chatGroupParseQuery.fromLocalDatastore()
                                    .findInBackground(new FindCallback<ParseObject>() {
                                        @Override
                                        public void done(List<ParseObject> list, ParseException e) {
                                            if (e == null) {
                                                l.d("Found " + list.size() + " chat groups from local datastore");
                                            } else {
                                                e.printStackTrace();
                                            }
                                        }
                                    });
                        } else {
                            e.printStackTrace();
                        }
                    }
                });
            } else {
                e.printStackTrace();
            }
        }
});

下面是日志:

Fetched chat group: ChatGroup { objectId: mOJGWRiLPC, name: Admin } from server
Successfully pinned chat group
Found 0 chat groups from local datastore

但是,这没有任何意义!我只是固定的对象,这样怎么能有在本地数据存储区0的对象。在code是如此简单。 我在做什么错了?难道是用SDK中的错误?结果
任何有识之士将大大AP preciated我一直在努力,现在找到了好几天的问题。

But this doesn't make any sense! I just pinned an object so how can there be 0 objects in the local datastore. The code is so simple. What am I doing wrong? Could it be a bug with the SDK?
Any insight will be much appreciated I have been trying to find the issue for days now.

解析设置看起来好像没什么问题:

The Parse setup looks fine to me:

    ParseObject.registerSubclass(ChatGroup.class);
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, AppProps.properties.appId,
            AppProps.properties.clientKey);
    ParseUser.enableRevocableSessionInBackground();
    Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);

请注意:


  • 它试图与ParseUser对象相同的逻辑时,工作正常。即使其他类矿山喜欢我的消息这使我怀疑,什么是错我的ChatGroup类。

  • 我已经添加了两个字段我的 ChatGroup 的parse.com数据浏览器类:名读取(String)和信息(关系),并写了一个角色的访问称为管理员。

  • 当浏览到实际的解析分贝(使用root访问权限),我发现数据库表( ParseObjects )确实包含了我寄托的行。但不知何故分析显示0结果上询问吧!

  • It works fine when trying the same logic with the ParseUser object. And even other classes of mine like my Message which leads me to suspect that something is wrong with my ChatGroup class.
  • I have added two fields to my ChatGroup class on the parse.com data browser: name(String) and messages(Relation) with read and wrote access to a role called Admin.
  • When browsing to the actual parse db (using root access) I find that the database table (ParseObjects) does contain the row that I pinned. But somehow parse shows 0 results on querying it!

推荐答案

我发现这个问题。这似乎是更像解析的Andr​​oid SDK中的错误。我使用Android SDK获取与特殊的ACL固定的对象范围缩小到一个问题。

I found the issue. It seems to be more like a bug with the Android SDK of parse. I narrowed it down to an issue with retrieving pinned objects with special ACLs using the Android SDK.

最初,对象有ACL等,只有角色管理员(我创建的)可以读取和写入。有趣的是,用户与我测试钉扎和查询是一个管理员!但是,当我改变了这样的ACL公众可以读,但只有管理员可以写,这个问题就解决了​​!

Initially, the object had the ACL such that only the role 'Admin' (that I created) can read and write. The funny thing is that the user with which I was testing the pinning and querying was an 'Admin'! But, when I changed the ACL such that public can read but only Admin can write, the problem was resolved!

我的理论是,查询本地数据存储就像一个公共查询,不管是什么角色没有这些发起查询的用户拥有的!但是,如果其他任何理论解释,这将是AP preciated。幸运的是,在我的情况,我需要公共读取权限,但是这个错误可能是一些谁需要有读访问限制的ACL一个巨大的垮台!希望parse.com很快就会解决这个问题。结果
这是一个相当大的问题!我很惊讶,我找不到对这个问题的问题。

My theory was that querying the local datastore behaves like a public query, no matter what role the user that is making the query has! But if any other theory explaining this would be appreciated. Luckily, in my case I need public read access, but this bug can be a huge downfall for some who need to have read access restricting ACLs! Hopefully parse.com will fix this issue soon.
This is quite a big issue! I am surprised that I couldn't find a question regarding this issue.

这篇关于ParseQuery即使成功寄希望于从本地数据存储,查询时给出0对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆