Back

Query.select ["attribute name.*"] doesn't return the attribute if it's a relationship

  • 0
  • Databases
  • Flutter
paritodev
1 Apr, 2024, 00:05

My document have a relationship "source"

If I query without doing a select, source is present in the attributes.

But if I do: Query.select( ["title", ..., "source.* ", ...systemAttributes]);

Based on this https://github.com/appwrite/appwrite/issues/5657, it should work.

But in my case, every attributes I include are present except the relationship one which is "source".

If I do : Query.select(["source.* ", ...systemAttributes]):

I have documents like this:

{$id: 6609f1fa3031203835fb, $createdAt: 2024-03-31T23:30:03.205+00:00, $updatedAt: 2024-03-31T23:30:03.205+00:00, $permissions: []}

Basically, source is never included.

But I know that at least the server recognize the request since doing it wrongly throw an error instead.

Query.select(["source", ...systemAttributes]):

Any idea?

TL;DR
Developers are experiencing an issue where the Query.select method is not returning the attribute if it's a relationship. The server recognizes the request but the expected attribute "source" is not included in the response. The suggested solution in a GitHub issue doesn't work. No queries work on relationships, and the issue persists even when attempting various methods. Further investigation or a bug fix might be required by the core team.
Kenny
1 Apr, 2024, 02:50

No queries work on relationships

paritodev
2 Apr, 2024, 02:16

🧐 I'm confused, why would appwrite Engineering Lead suggest a solution that doesn't actually work?

paritodev
2 Apr, 2024, 02:18

I mean, it's not even a suggestion, it's presented as though it is the actual solution to this specific isue then the github issue was marked as completed without any mention of this not actually working or being something that should be present in the future, not the present day.

Kenny
2 Apr, 2024, 02:37

Maybe someone from the core team will have to come and check this out. It could be a bug that that doesn’t work. I’m not entirely sure.

Kenny
2 Apr, 2024, 02:38

I can throw together a POC sometime tomorrow to verify I get the same behavior

Kenny
2 Apr, 2024, 13:42

Let me know if I'm missing something, but here is my POC, and it looks like it's working.

Kenny
2 Apr, 2024, 13:42
paritodev
3 Apr, 2024, 20:17

Sorry for the late response, I am on vacation.

Can you possibly try this POC again on with the flutter appwrite package version 11.0.1? Or I can post my own barebone code on github. I tried again with the most barebone implementation client side (but still the same project server side), but I'm still getting the same issue:

With this query : Query.select(["source.*", ...systemAttributes]);

I have this this result :

{$id: 65df580ee8de480290fd, $createdAt: 2024-02-28T15:58:06.956+00:00, $updatedAt: 2024-02-28T15:58:06.956+00:00, $permissions: []}

The source is still nowhere to be seen, but I know at least that the server do recognize the query since if I mispell "source", for example in this query : Query.select(["fakeSource.*", ...systemAttributes]);

I have this error :

AppwriteException: general_query_invalid, Invalid query: Attribute not found in schema: fakeSource (400)#0

paritodev
3 Apr, 2024, 20:25

Also, the reason why I'm not directly sharing the code is because I'm on a very limited network currently but if it's needed to help resolve this issue, I will do it.

paritodev
3 Apr, 2024, 20:31

What I really don't know is wether the appwrite package is tampering with the server response somehow or is the server just not giving the appropriate response back depending on the client that's requesting (maybe this specific feature is disabled for this specific appwrite version I don't know, but I think that's odd and probably not the case given the date of the github posts and responses.)

Tessa
3 Apr, 2024, 20:56

@paritodev is this a related PR that could fix your issue? I think this involves making querying relational data work, as well as fixing a few other issues with relationships https://github.com/utopia-php/database/pull/400

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more