浏览代码

ensure types (#215)

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
ryjiang 2 年之前
父节点
当前提交
a6ff654ad8
共有 2 个文件被更改,包括 14 次插入9 次删除
  1. 2 3
      client/src/pages/collections/Types.ts
  2. 12 6
      client/src/pages/dialogs/CreateCollectionDialog.tsx

+ 2 - 3
client/src/pages/collections/Types.ts

@@ -98,12 +98,11 @@ export interface Field {
   id?: string;
   type_params?: {
     dim?: string | number;
-    max_length?: string;
+    max_length?: string | number;
   };
   createType?: CreateFieldType;
-  max_length?: string | null;
+  max_length?: string | number | null;
   autoID?: boolean;
-  
 }
 
 export type CreateFieldType =

+ 12 - 6
client/src/pages/dialogs/CreateCollectionDialog.tsx

@@ -184,16 +184,22 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {
     const param: CollectionCreateParam = {
       ...form,
       fields: fields.map(v => {
-        const data: Field = {
+        let data: Field = {
           name: v.name,
           description: v.description,
           is_primary_key: v.is_primary_key,
           is_partition_key: v.is_partition_key,
           data_type: v.data_type,
-          dimension: vectorType.includes(v.data_type) ? v.dimension : undefined,
-          max_length: v.max_length,
+          dimension: vectorType.includes(v.data_type)
+            ? Number(v.dimension)
+            : undefined,
         };
 
+        // if we need
+        if (typeof v.max_length === 'number') {
+          data.max_length = Number(v.max_length);
+        }
+
         v.is_primary_key && (v.autoID = form.autoID);
 
         return vectorType.includes(v.data_type)
@@ -201,17 +207,17 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {
               ...data,
               type_params: {
                 // if data type is vector, dimension must exist.
-                dim: data.dimension!,
+                dim: Number(data.dimension!),
               },
             }
           : v.data_type === DataTypeEnum.VarChar
           ? {
               ...v,
               type_params: {
-                max_length: v.max_length!,
+                max_length: Number(v.max_length!),
               },
             }
-          : v;
+          : { ...data };
       }),
       consistency_level: consistencyLevel,
     };