8000 🚀 Feature: Improving the Select Query · Issue #5376 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🚀 Feature: Improving the Select Query #5376

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

Open
2 of 7 tasks
moshOntong-IT opened this issue Apr 14, 2023 · 4 comments
Open
2 of 7 tasks

🚀 Feature: Improving the Select Query #5376

moshOntong-IT opened this issue Apr 14, 2023 · 4 comments
Labels
product / databases Fixes and upgrades for the Appwrite Database.

Comments

@moshOntong-IT
Copy link
moshOntong-IT commented Apr 14, 2023

👟 Reproduction steps

  1. Query the vocabulary collection with relationship in language collection.

Vocabulary -> language
vocabulary can contain one language
language can belong to many vocabulary

Sample code:

      final documents = await databases.listDocuments(
          databaseId: kDatabaseId,
          collectionId: kVocabularyCollectionId,
          queries: [
            Query.equal("language", languageSelected.languageId),
          ]);

The payload code of this is this:
image

Please observe that in our data key with the index of 6 namely language key. It provide all the attributes of our language object/document. Now trying to query by using the new Queries Query.select(['language.\$id']) though the new queries is not yet supported in Appwrite 1.3 version, hence it is expected it gives me an error output. But if I use only this Query.select([]). The whole code:

      final documents = await databases.listDocuments(
          databaseId: kDatabaseId,
          collectionId: kVocabularyCollectionId,
          queries: [
            Query.select([]),
            Query.equal("language", languageSelected.languageId),
          ]);

The payload output of the code:

image

Please observe on the encircle of the attach picture above. It is weird right? it only provide the language ID, though the Query select is not yet available on current version of Appwrite.

👍 Expected behavior

If we use this query Query.select(['language.\$id']) the output should provide only the language ID in our language payload.

👎 Actual Behavior

Not working

But I understand, this query is not available yet, But its weird that by using this Query.select([]) it successfully give me the only $id attribute of language.

Note that without using this Query.select it does give me all the attributes in my language object within payload returned from listDocuments

📝 Tasks

🎲 Appwrite version

Version 1.3.x

💻 Operating system

Windows

🧱 Your Environment

No response

👀 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?

@moshOntong-IT moshOntong-IT added the bug Something isn't working label Apr 14, 2023
@joeyouss
Copy link

Thank you for opening this

@joeyouss joeyouss added the product / databases Fixes and upgrades for the Appwrite Database. label Apr 14, 2023
@stnguyen90
Copy link
Contributor

Another odd thing:

Given:

{
  "$id": "64542e0a4656d6d829d5",
  "$createdAt": "2023-05-04T22:13:30.299+00:00",
  "$updatedAt": "2023-05-04T22:13:30.299+00:00",
  "$permissions": [
    "read(\"user:joe\")",
    "update(\"user:joe\")",
    "delete(\"user:joe\")"
  ],
  "answerChoice": {
    "value": "A",
    "text": "Facebook",
    "$id": "64542d132dbfa638c95f",
    "$createdAt": "2023-05-04T22:09:23.207+00:00",
    "$updatedAt": "2023-05-04T22:09:23.207+00:00",
    "$permissions": [],
    "question": {
      "text": "Who created Flutter?",
      "$id": "64542d132d90428be1d5",
      "$createdAt": "2023-05-04T22:09:23.207+00:00",
      "$updatedAt": "2023-05-04T22:09:23.411+00:00",
      "$permissions": [],
      "$databaseId": "default",
      "$collectionId": "questions"
    },
    "correctAnswer": null,
    "$databaseId": "default",
    "$collectionId": "answer-choices"
  },
  "$databaseId": "default",
  "$collectionId": "answers"
}

a select query like:

select(["answerChoice.question.text", "answerChoice.value", "answerChoice.text"])

should return something like:

{
  "answerChoice": {
    "value": "A",
    "text": "Facebook",
    "question": {
      "text": "Who created Flutter?"
    }
  }
}

but it returns:

{
  "$id": "64542e0a4656d6d829d5",
  "$createdAt": "2023-05-04T22:13:30.299+00:00",
  "$updatedAt": "2023-05-04T22:13:30.299+00:00",
  "$permissions": [
    "read(\"user:joe\")",
    "update(\"user:joe\")",
    "delete(\"user:joe\")"
  ],
  "answerChoice": {
    "value": "A",
    "text": "Facebook",
    "$id": "64542d132dbfa638c95f",
    "$createdAt": "2023-05-04T22:09:23.207+00:00",
    "$updatedAt": "2023-05-04T22:09:23.207+00:00",
    "$permissions": [],
    "$databaseId": "default",
    "$collectionId": "answer-choices"
  },
  "$databaseId": "default",
  "$collectionId": "answers"
}

@byawitz
Copy link
Member
byawitz commented May 11, 2023

I think the load of the other default fields is still set to be returned when there is a specific select

https://github.com/utopia-php/database/blob/main/src/Database/Adapter/MariaDB.php#L1190

@Musta-Pollo
Copy link
Musta-Pollo commented May 16, 2023

Currently, with select([]), there is an option to load only the id of a related document or nothing if there is a list of related documents. This behavior should be persistent, as we should have the option to disable the loading of relations if we don't need them without the need to specify everything except relations.

maybe Query.unselect([])? I don't know how hard this would be on the backend side

@stnguyen90 stnguyen90 removed the bug Something isn't working label Jun 13, 2023
@stnguyen90 stnguyen90 changed the title 🐛 Bug Report: The weird result of Query Select in relationshiop 🐛 Bug Report: Improving the Select Query Jun 13, 2023
@stnguyen90 stnguyen90 changed the title 🐛 Bug Report: Improving the Select Query 🚀 Feature: Improving the Select Query Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

5 participants
0