Retrieving data from parent object of child object - unexpected result

Hi everyone!
Help or advice needed.

There a 2 records in table “ElectoralCampaigns”, each of them have relation with 1 different record in table “CampaignHQ”.
First related record in “CampaignHQ” have one parent object in table “CampaignParticipants”. We can see it in property “CampaignParticipants[CampaignHQ]”.
Second related record has two of them.
All three related objects in table “CampaignParticipants” are different.
Each of them have different value in string property “role”. (nothing common with user’s role)
(all mentioned connections is 1:N)

I wanna get a list of all “ElectoralCampaigns” with corresponding “role” property.

So I making GET request:
https://api.backendless.com/................../data/ElectoralCampaigns?property=CampaignHQ.CampaignParticipants[CampaignHQ].role

I expect 3 objects, all with different value of propery “role”. But it shows the same “role” for second and third object. I don’t understand, why it like that.
image

APP ID: C18079E8-47F1-B85B-FF69-59B92D497200

Hi Nikolay,

How about attaching a screenshot of the database schema diagram? It would make it so much easier to understand the relationships between the tables.

Regards,
Mark

Of course, my bad.

For clarification:
ElectoralCampaign will always have connection with one CampaignHQ, and CampaignHQ may have connections with many CampaignPartisipants.
But in the end I don’t need roles of all connected CampaignPartisipants. Only of one, based on specific creteria. But that’s another step.

Hello, @Nikolay_Neustroev.

Could you please provide your app id?

Regards, Nikita.

Nikita, hello.

APP ID: C18079E8-47F1-B85B-FF69-59B92D497200

Hi, Nikolay.
We’ve changed the behaviour of your app. Please, check it now.
Also, please, keep in mind, that you will receive only those properties, which you enumerate directly or all of them if set nothing.
In case of relations – you will receive cross-intersections of the requested objectss. And even if at a first glance they seem the same it is only because you didn’t ask about the property which is different. In this case if you do not want cross-intersections, just add to the request parameter **distinct=true.**

Will wait for you response, whether everything is correct now.

Hello, Oleg. Thank you for your help! Now this query works as I expected.
To be honest, I don’t understand your explanation about cross-intersections yet, but I think it will come for me later.
I only wanna ask: what have you changed in my app exactly?

We added new functionality to provide ability of working with cross-intersections.
Such behaviour woks only in the new apps, and your app was created before such changes.
So, you can think of it as simply “switching” to a new mode of operation.

p.s.
About cross-intersections. Try this:
Create two tables with at least one custom field, create relation from table A to table B.
Add two records in both tables. Link every object from table A to the both objects in table B.
Perform request to the table A, but try to get field from related objects (table B) – you’ll get 4 objects.
Because they are not objects from table A or table B – the are compilations of two objects.
It is a cross-intersection.

Got it now, thanks again! :slight_smile: