Parse-SDK-Flutter icon indicating copy to clipboard operation
Parse-SDK-Flutter copied to clipboard

not used selectKey function

Open catalunha opened this issue 1 year ago • 3 comments

New Issue Checklist

Issue Description

In the Parse SDK flutter has this 'selectKeys' function which, besides being poorly documented, I believe is in conflict with another one already developed. Some tests I performed did not return any values. It would be possible for you to analyze whether this function is useful in Parse SDK flutter and what would be a more detailed description of its use or a brief example so that I can better understand how to use this function.

Steps to reproduce


void learningAboutB4aTestSelectKeys() async {
  print('Start');
  await initialize();
  QueryBuilder<ParseObject> query =
      QueryBuilder<ParseObject>(ParseObject('Table3'));
  query.selectKeys('colB', 'a');
  var parseResponse = await query.query();

  if (parseResponse.success && parseResponse.results != null) {
    for (var element in parseResponse.results!) {
      ParseObject parseObject = element as ParseObject;
      print('+++');
      print(parseObject);
      print('---');
    }
  }
  print('End');
}

Future<void> initialize() async {
  String applicationId = '...';
  String clientKey = '...';
  String serverUrl = 'https://parseapi.back4app.com';
  await Parse().initialize(
    applicationId,
    serverUrl,
    clientKey: clientKey,
    debug: false,
  );
  if ((await Parse().healthCheck()).success) {
    print('Back4app Connected.');
  } else {
    print('Back4app NOT Connected.');
    print('Exit app.');
    exit(0);
  }
}


Actual Outcome

None

Expected Outcome

Unknown

Environment

parse_server_sdk: ^4.0.2

Parse Flutter SDK

  • SDK version: parse_server_sdk: ^4.0.2
  • Flutter version: 3.7.12
  • Dart version: 2.19.6
  • Operating system version: Linux

Server

  • Parse Server version: 5.2.3 in back4app

Logs

catalunha avatar May 07 '23 18:05 catalunha

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

I found this on the other SDKs JS

  /**
   * Adds a constraint that requires that a key's value matches a value in
   * an object returned by a different Parse.Query.
   *
   * @param {string} key The key that contains the value that is being
   *                     matched.
   * @param {string} queryKey The key in the objects returned by the query to
   *                          match against.
   * @param {Parse.Query} query The query to run.
   * @returns {Parse.Query} Returns the query, so you can chain this call.
   */
  matchesKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery {
    const queryJSON = query.toJSON();
    queryJSON.className = query.className;
    return this._addCondition(key, '$select', {
      key: queryKey,
      query: queryJSON,
    });
  }

Android

    // TODO(grantland): Convert mutable parameter to immutable t6941155
            public Builder<T> whereMatchesKeyInQuery(
                    String key, String keyInQuery, Builder<?> builder) {
                Map<String, Object> condition = new HashMap<>();
                condition.put("key", keyInQuery);
                condition.put("query", builder);
                return addConditionInternal(
                        key, "$select", Collections.unmodifiableMap(new HashMap<>(condition)));
            }

But I don't know if the original creator of this SDK (Flutter SDK) intended to include the same functionality as the other SDKs

Nidal-Bakir avatar May 07 '23 21:05 Nidal-Bakir

I found this on the other SDKs JS

  /**
   * Adds a constraint that requires that a key's value matches a value in
   * an object returned by a different Parse.Query.
   *
   * @param {string} key The key that contains the value that is being
   *                     matched.
   * @param {string} queryKey The key in the objects returned by the query to
   *                          match against.
   * @param {Parse.Query} query The query to run.
   * @returns {Parse.Query} Returns the query, so you can chain this call.
   */
  matchesKeyInQuery(key: string, queryKey: string, query: ParseQuery): ParseQuery {
    const queryJSON = query.toJSON();
    queryJSON.className = query.className;
    return this._addCondition(key, '$select', {
      key: queryKey,
      query: queryJSON,
    });
  }

Android

    // TODO(grantland): Convert mutable parameter to immutable t6941155
            public Builder<T> whereMatchesKeyInQuery(
                    String key, String keyInQuery, Builder<?> builder) {
                Map<String, Object> condition = new HashMap<>();
                condition.put("key", keyInQuery);
                condition.put("query", builder);
                return addConditionInternal(
                        key, "$select", Collections.unmodifiableMap(new HashMap<>(condition)));
            }

But I don't know if the original creator of this SDK (Flutter SDK) intended to include the same functionality as the other SDKs

There is this function called whereMatchesKeyInQuery in parse_query

It seems that the selectKeys and dontSelectKeys functions have been implemented twice! with the names whereMatchesKeyInQuery and whereDoesNotMatchKeyInQuery!

Also, the selectKeys and dontSelectKeys functions seem to be not designed correctly!

mbfakourii avatar May 23 '23 13:05 mbfakourii