From 17509626c7ae6ba193038c3cb47a8265f2e331c3 Mon Sep 17 00:00:00 2001 From: ryjiang Date: Wed, 25 Dec 2024 19:50:03 +0800 Subject: [PATCH] fix Client behaviour for output_fields differs from documentation (#398) Signed-off-by: ryjiang --- milvus/grpc/Data.ts | 1 + test/grpc/Data.spec.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/milvus/grpc/Data.ts b/milvus/grpc/Data.ts index 9ee27b4e..84716aa0 100644 --- a/milvus/grpc/Data.ts +++ b/milvus/grpc/Data.ts @@ -977,6 +977,7 @@ export class Data extends Collection { 'Query', { ...data, + output_fields: data.output_fields || ['*'], query_params: parseToKeyValue({ ...limits, ...offset }), }, data.timeout || this.timeout diff --git a/test/grpc/Data.spec.ts b/test/grpc/Data.spec.ts index 7bb8a631..78c9451c 100644 --- a/test/grpc/Data.spec.ts +++ b/test/grpc/Data.spec.ts @@ -573,6 +573,20 @@ describe(`Data.API`, () => { expect(res4.data.length).toBe(default_values.length); }); + it(`Query withouth output fields should success`, async () => { + const res = await milvusClient.query({ + collection_name: COLLECTION_NAME, + expr: 'id > 0', + offset: 0, + limit: 3, + }); + + expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); + expect(res.data.length).toBe(3); + // fields of data should > 1 + expect(Object.keys(res.data[0]).length).toBeGreaterThan(1); + }); + it(`Query with count(*)`, async () => { const queryString = 'count(*)'; const res = await milvusClient.query({