Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There might be a bug on Android 4 while query relational data #674

Closed
IHNEL opened this issue Jun 1, 2017 · 2 comments
Closed

There might be a bug on Android 4 while query relational data #674

IHNEL opened this issue Jun 1, 2017 · 2 comments

Comments

@IHNEL
Copy link

IHNEL commented Jun 1, 2017

I have 2 tables: Task and User. The relationship between them is n-n, a user can be a host or participant of a task.

I used below function to query for the list of tasks of user with given userId. This function should return all tasks that this user created and tasks that other users added him as participant.

override fun getTaskList(userId: String): List<TaskDto> {
        val user = ParseUser.createWithoutData("_User", userId)
        val hostQuery = ParseQuery
                .getQuery(TaskDto::class.java)
                .whereEqualTo(TaskDto::host.name, user)

        val participantQuery = ParseQuery
                .getQuery(TaskDto::class.java)
                .whereEqualTo(TaskDto::participants.name, user)

        var compoundQuery = ParseQuery
                .or(listOf(hostQuery, participantQuery))
                .include(Task::participants.name)
                .include(Task::host.name)
               
       try {
            val dataList = compoundQuery.find()
            return dataList
        } catch (e: ParseException) {
            e.printStackTrace()
            return emptyList()
        }
    }

The function work well on Android 5+, but on Android 4 (API 16), I can't get the tasks that given user is participant of. The data type of column participants is Array of Pointers. It contains value like this:

[{"__type":"Pointer","className":"_User","objectId":"ZVp6AwWCA7"},{"__type":"Pointer","className":"_User","objectId":"SoN1XRKwXi"}]

Assume user A logged in to Android-4 phone, and user B logged in to Android-5 phone. if A create a task and invite B as participant, both B and A can query it. but if B create a task and invite A as participant, only B can see.

I did debug and see that the participantQuery always return empty list on Android-4.

Did I do any mistake? Or is it a bug of Parse SDK?

@natario1
Copy link
Contributor

natario1 commented Jun 1, 2017

@IHNEL which parse-server version are you using?

We already have a similar ticket ( #514 ) and it seems that parse-server 2.4.0 fixes this. Can you confirm?

@IHNEL
Copy link
Author

IHNEL commented Jun 5, 2017

Thank you @natario1 . The problem has gone when I upgrade the version of Parse Server to 2.4.0.

@IHNEL IHNEL closed this as completed Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants