Browse Source

fix bool data display

czhen 3 years ago
parent
commit
2175fd5c1a
1 changed files with 8 additions and 3 deletions
  1. 8 3
      client/src/pages/query/Query.tsx

+ 8 - 3
client/src/pages/query/Query.tsx

@@ -58,7 +58,7 @@ const Query: FC<{
         const tmp = Object.keys(resultItem).reduce(
           (prev: { [key: string]: any }, item: string) => {
             if (Array.isArray(resultItem[item])) {
-              const list2Str = `[${resultItem[item]}]`;
+              const list2Str = JSON.stringify(resultItem[item]);
               prev[item] = (
                 <div className={classes.vectorTableCell}>
                   <div>{list2Str}</div>
@@ -70,7 +70,7 @@ const Query: FC<{
                 </div>
               );
             } else {
-              prev[item] = resultItem[item];
+              prev[item] = `${resultItem[item]}`;
             }
             return prev;
           },
@@ -107,9 +107,14 @@ const Query: FC<{
 
   const getFields = async (collectionName: string) => {
     const schemaList = await FieldHttp.getFields(collectionName);
+    const generateDataType = (rawType: string) => {
+      if (rawType.includes('Int')) return 'int';
+      if (rawType.includes('Bool')) return 'bool';
+      return 'float';
+    };
     const nameList = schemaList.map(v => ({
       name: v.name,
-      type: v.data_type.includes('Int') ? 'int' : 'float',
+      type: generateDataType(v.data_type),
     }));
     const primaryKey =
       schemaList.find(v => v._isPrimaryKey === true)?._fieldName || '';