Skip to content

IllegalStateExceptions thrown when using query.selectKeys() #595

@natario1

Description

@natario1

I am inclined to believe that this is a Android SDK bug rather than parse-server.

Steps to reproduce:

  1. Create a TestTable like the following, with just to objects:

     key:        foo            bar           else
                 “yes”          111           “unwanted key”
                 “yes”                        “unwanted key”
    

    That is,

     ParseObject o1 = new ParseObject(“TestTable”);
     o1.set(“foo”, “yes”);
     o1.set(“bar”, 111);
     o1.set(“else”, “unwanted key”);
     o1.save();
     ParseObject o2 = new ParseObject(“TestTable”);
     o2.set(“foo”, “yes”);
     o2.set(“else”, “unwanted key”);
     o2.save();
    
  2. No issues arise if you call find() as is:

     ParseQuery q = ParseQuery.getQuery(“TestTable”);
     List<ParseObject> objs = q.find();
    

    Calling obj.getInt(“bar”) will return 111 for the first object, 0 for the second.
    That’s what we are used to.

  3. But if we want to exclude the “else” key,

     ParseQuery q = ParseQuery.getQuery(“TestTable”);
     q.selectKeys(Arrays.asList(“foo”, “bar”));
     List<ParseObject> objs = q.find();
    

    Calling obj.getInt(“bar”) returns 111 for the first object indeed, but throws an exception for the first object, the IllegalStateException asking you to fetch the object.

I hope the report is clear: if a selected key exists in the server but is simply undefined, obj.has(“key”) incorrectly returns false obj.get(“key”) incorrectly throws. This makes selectKeys() useless for any table that might have some undefined data among the selected keys. I am surprised this was not brought up yet.

Note: make sure to wipe out app cache between point 2 or 3, or 3 will work because the object is cached. Or, just test 3. before testing 2.

Thank you @rogerhu for stepping up, I am happy to see this back on track.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions