parse-community / Parse-SDK-Flutter

The Dart/Flutter SDK for Parse Platform
https://parseplatform.org
Apache License 2.0
575 stars 190 forks source link

not used selectKey function #871

Open catalunha opened 1 year ago

catalunha commented 1 year ago

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

Server

Logs

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

Nidal-Bakir commented 1 year ago

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

mbfakourii commented 1 year ago

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!