dart_algolia icon indicating copy to clipboard operation
dart_algolia copied to clipboard

Type 'List<String>' is not a subtype of type 'String' in `AlgoliaMultiIndexesReference`

Open SebastianWaloszek opened this issue 1 year ago • 2 comments

Dart version: 2.18.6 Flutter version: 3.3.10 (stable)

Describe the bug When one sets a list of facet filters for a query to be performed as part of getObjects() inside AlgoliaMultiIndexesReference there's an encoding error being thrown.

dart:core                                        new _Uri
package:algolia/src/index_reference.dart 358:23  AlgoliaMultiIndexesReference._encodeMap
package:algolia/src/index_reference.dart 391:19  AlgoliaMultiIndexesReference.getObjects
test/algolia_test.dart 158:43                    main.<fn>.<fn>

type 'List<String>' is not a subtype of type 'String'

It only happens for AlgoliaMultiIndexesReference. When we try doing the same for AlgoliaIndexReference it works without issues.

To Reproduce One can reproduce the issue in tests by adding a list of facet filters:

      queryA = queryA.facetFilter([
        'email:[email protected]',
        'email:[email protected]',
      ]);

in the Perform Multiple Queries test like this:

    test('Perform Multiple Queries', () async {
      var queryA = algolia.instance.index('contacts').query('john');
      var queryB = algolia.instance.index('contacts_alt').query('jo');

      // Perform multiple facetFilters
      queryA = queryA.facetFilter('status:published');
      queryA = queryA.facetFilter('isDelete:false');
      queryA = queryA.facetFilter([
        'email:[email protected]',
        'email:[email protected]',
      ]);

      try {
        // Get Result/Objects
        var snap = await algolia.multipleQueries
            .addQueries([queryA, queryB]).getObjects();
        // Checking if has [List<AlgoliaQuerySnapshot>]
        expect(snap.length, 2);
        print('Queries count: ${snap.length}');
      } on AlgoliaError catch (err) {
        print(err.error.toString());
        expect(err.runtimeType, AlgoliaError);
      }
      print('\n\n');
    });

Expected behavior Encoding error should not happen inside AlgoliaMultiIndexesReference when the set facet filter for a query is a List<String>.

SebastianWaloszek avatar Mar 23 '23 13:03 SebastianWaloszek

I have proposed a solution to this issue in this PR: https://github.com/knoxpo/dart_algolia/pull/116

SebastianWaloszek avatar Mar 23 '23 13:03 SebastianWaloszek

The problem still exist. Can you guy's add his PR ?

jeremyKos avatar Jun 06 '24 08:06 jeremyKos