From 645c8400845c30ce4a5d86c58abef77141934777 Mon Sep 17 00:00:00 2001 From: purplenicole730 Date: Thu, 19 Dec 2024 16:24:18 -0500 Subject: [PATCH 1/3] change query to be dynamic --- lib/src/app/data.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/src/app/data.dart b/lib/src/app/data.dart index 90348f3abe..3ec6753724 100644 --- a/lib/src/app/data.dart +++ b/lib/src/app/data.dart @@ -95,10 +95,18 @@ class DataClient { /// Obtain unified tabular data and metadata, queried with MQL. /// /// For more information, see [Data Client API](https://docs.viam.com/appendix/apis/data-client/). - Future>> tabularDataByMql(String organizationId, List query) async { + Future>> tabularDataByMql(String organizationId, dynamic query) async { + List binary; + if (query is List>) { + binary = query.map((q) => BsonCodec.serialize(q).byteList).toList(); + } else if (query is List) { + binary = query; + } else { + throw TypeError(); + } final request = TabularDataByMQLRequest() ..organizationId = organizationId - ..mqlBinary.addAll(query); + ..mqlBinary.addAll(binary); final response = await _dataClient.tabularDataByMQL(request); return response.rawData.map((e) => BsonCodec.deserialize(BsonBinary.from(e))).toList(); } From 2069cb5351e610a8514abccbc997e8930e30cfc6 Mon Sep 17 00:00:00 2001 From: purplenicole730 Date: Thu, 19 Dec 2024 16:24:23 -0500 Subject: [PATCH 2/3] add comment --- lib/src/app/data.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/app/data.dart b/lib/src/app/data.dart index 3ec6753724..a27191173f 100644 --- a/lib/src/app/data.dart +++ b/lib/src/app/data.dart @@ -92,7 +92,7 @@ class DataClient { return response.rawData.map((e) => BsonCodec.deserialize(BsonBinary.from(e))).toList(); } - /// Obtain unified tabular data and metadata, queried with MQL. + /// Obtain unified tabular data and metadata, queried with MQL. The query should be of type List>. /// /// For more information, see [Data Client API](https://docs.viam.com/appendix/apis/data-client/). Future>> tabularDataByMql(String organizationId, dynamic query) async { From 483a93f692b81df56d9547e9fdfe7dd280983177 Mon Sep 17 00:00:00 2001 From: purplenicole730 Date: Thu, 19 Dec 2024 16:27:43 -0500 Subject: [PATCH 3/3] change test to use list of maps --- test/unit_test/app/data_client_test.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/unit_test/app/data_client_test.dart b/test/unit_test/app/data_client_test.dart index 01f12f1199..72386c3494 100644 --- a/test/unit_test/app/data_client_test.dart +++ b/test/unit_test/app/data_client_test.dart @@ -162,6 +162,9 @@ void main() { }); test('tabularDataByMql', () async { + final List> query = [ + {'key': 'value'} + ]; final startDate = DateTime.utc(2020, 12, 31); final List> data = [ { @@ -175,7 +178,7 @@ void main() { when(serviceClient.tabularDataByMQL(any)).thenAnswer( (_) => MockResponseFuture.value(TabularDataByMQLResponse()..rawData.addAll(data.map((e) => BsonCodec.serialize(e).byteList)))); - final response = await dataClient.tabularDataByMql('some_org_id', [Uint8List.fromList('some_query'.codeUnits)]); + final response = await dataClient.tabularDataByMql('some_org_id', query); expect(response[0]['key1'], equals(data[0]['key1'])); expect(response, equals(data)); });