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

🐛 Bug Report: Query.select() fails on querying relationships #5657

Closed
2 tasks done
asjustis opened this issue Jun 5, 2023 · 1 comment
Closed
2 tasks done

🐛 Bug Report: Query.select() fails on querying relationships #5657

asjustis opened this issue Jun 5, 2023 · 1 comment
Assignees
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.

Comments

@asjustis
Copy link

asjustis commented Jun 5, 2023

👟 Reproduction steps

const db = new Databases(client);
const response = await db.listDocuments(
      DB_ID,
      COLECTION_PRACTICES,
      Query.select(['title', 'description', 'intro', 'exercises']), // here title, description, intro are strings; exercises is relationship
    );
return response.documents;

👍 Expected behavior

It should correctly allow getting exercises relationship object plus allow querying filtered relationship fields like exercises.title, etc.

👎 Actual Behavior

The code returns an error I am logging:

[Error: Failed to fetch practices. AppwriteException: Invalid queries: Value must a valid array and Value must be a valid string and at least 1 chars and no longer than 4096 chars]

Both skipping the exercises value or removing Query.select() works correctly and returns full objects.

🎲 Appwrite version

Version 1.3.x

💻 Operating system

MacOS

🧱 Your Environment

Appwrite 1.3.x version, using through Web SDK on React Native

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@asjustis asjustis added the bug Something isn't working label Jun 5, 2023
@joeyouss joeyouss self-assigned this Jun 12, 2023
@stnguyen90 stnguyen90 added the product / databases Fixes and upgrades for the Appwrite Database. label Jun 13, 2023
@abnegate
Copy link
Contributor

Hey @asjustis, the issue here is that the queries need to be an array, you can fix it like this:

const response = await db.listDocuments(
      DB_ID,
      COLECTION_PRACTICES,
      [Query.select(['title', 'description', 'intro', 'exercises.*'])], // here title, description, intro are strings; exercises is relationship
    );

Note the exercises.*, this is how you select all attributes of a relationship

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

4 participants