Stringify nested objects in sql query responses (#430)
This commit is contained in:
parent
372fb3b33d
commit
5eb4d27297
|
|
@ -16,7 +16,7 @@ import FormControlFactory from "utils/FormControlFactory";
|
|||
import { HelpBaseURL, HelpMap } from "constants/HelpConstants";
|
||||
import Button from "components/editorComponents/Button";
|
||||
import { Datasource } from "api/DatasourcesApi";
|
||||
import { reduxForm, InjectedFormProps, Field } from "redux-form";
|
||||
import { reduxForm, InjectedFormProps } from "redux-form";
|
||||
import { BaseButton } from "components/designSystems/blueprint/ButtonComponent";
|
||||
import { APPSMITH_IP_ADDRESS } from "constants/DatasourceEditorConstants";
|
||||
import { getAppsmithConfigs } from "configs";
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import {
|
|||
import { useTable, useFlexLayout } from "react-table";
|
||||
import styled from "styled-components";
|
||||
import { CompactModeTypes, TABLE_SIZES } from "widgets/TableWidget";
|
||||
import AutoToolTipComponent from "components/designSystems/appsmith/AutoToolTipComponent";
|
||||
import { getType, Types } from "utils/TypeHelpers";
|
||||
|
||||
interface TableProps {
|
||||
data: Record<string, any>[];
|
||||
|
|
@ -30,6 +32,38 @@ const StyledTableWrapped = styled(TableWrapper)`
|
|||
}
|
||||
`;
|
||||
|
||||
const renderCell = (props: any) => {
|
||||
const value = props.cell.value;
|
||||
let displayValue;
|
||||
switch (getType(value)) {
|
||||
case Types.NUMBER:
|
||||
case Types.BOOLEAN:
|
||||
displayValue = value.toString();
|
||||
break;
|
||||
case Types.ARRAY:
|
||||
case Types.FUNCTION:
|
||||
case Types.OBJECT:
|
||||
displayValue = JSON.stringify(value);
|
||||
break;
|
||||
case Types.STRING:
|
||||
displayValue = value;
|
||||
break;
|
||||
case Types.NULL:
|
||||
case Types.UNDEFINED:
|
||||
case Types.UNKNOWN:
|
||||
displayValue = "";
|
||||
break;
|
||||
default:
|
||||
displayValue = "";
|
||||
}
|
||||
|
||||
return (
|
||||
<AutoToolTipComponent title={displayValue}>
|
||||
{displayValue}
|
||||
</AutoToolTipComponent>
|
||||
);
|
||||
};
|
||||
|
||||
const Table = (props: TableProps) => {
|
||||
const data = React.useMemo(() => props.data, [props.data]);
|
||||
const columns = React.useMemo(() => {
|
||||
|
|
@ -38,6 +72,7 @@ const Table = (props: TableProps) => {
|
|||
return {
|
||||
Header: key,
|
||||
accessor: key,
|
||||
Cell: renderCell,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user