Back

Trying to understand the Appwrite SDK Generator for Flutter with a bug reported with #742 on GitHub

  • 0
  • Flutter
عبد الرحمن
1 Jan, 2024, 11:49

I was trying to learn how the sdk process is working with the following issue number. https://github.com/appwrite/sdk-generator/issues/742 According to this issue this problem is related to search query. It says When I search “new soya” for the attribute “name”. e.g: Query.search(“name”, “new soya bean”) The data should return the value that starts or contains with the words “new soya bean” in that specific order.

👎 Actual Behavior The data returned is all the data that starts or contain with the words “new”, then the data that starts or contains with the words “soya”, and lastly the data that starts or contains with the words “bean”.

So the problem is so far with the Query class. When I look into the repository with the Query.dart.twig file it have the following code in this class.

TypeScript
static String _addQuery(String attribute, String method, dynamic value) => (value
          is List)
      ? '$method("$attribute", [${value.map((item) => _parseValues(item)).join(",")}])'
      : '$method("$attribute", [${_parseValues(value)}])';

  static String _parseValues(dynamic value) =>
      (value is String) ? '"$value"' : '$value';

and the search function is like this

TypeScript
 static String search(String attribute, String value) =>
      _addQuery(attribute, 'search', value);

As far as I understand it generates a simple string. Where is the actual dart implementation of the search function? Will someone please help me in the right direction?

TL;DR
User is seeking clarification on a bug reported with the Appwrite SDK Generator for Flutter. The bug affects the search query functionality, where the expected behavior is to return data that starts or contains words in a specific order, but instead, it returns data that starts or contains the words in any order. The issue seems to be with the Query class and its implementation. User is asking for help in finding the actual dart implementation of the search function. The bug has been reported on GitHub under issue #742. Solution: It appears that there is a bug in the frontend regex, where invalid input is caught on the backend but not in the SDK.
ideclon
1 Jan, 2024, 12:03

That search behaviour is actually the intended behaviour. The search Query is effectively the MySQL FULLTEXT search - you can look that up to see how it behaves.

The Issue linked seems to be a frontend regex bug. The issue is that an invalid input is caught on the backend, but not in the SDK.

عبد الرحمن
1 Jan, 2024, 12:46

My bad, I think I added the wrong issue link in the post. The correct issue I was refereing to is following https://github.com/appwrite/sdk-generator/issues/742

عبد الرحمن
1 Jan, 2024, 12:47

But I guess your answers seems valid for this issue as well?

ideclon
1 Jan, 2024, 13:09

Yep

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