mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-08 20:39:44 +00:00
fix(web): Fix sql format error (#1319)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Datum } from '@antv/ava';
|
||||
import { Table, Tabs, TabsProps } from 'antd';
|
||||
import React from 'react';
|
||||
import { format } from 'sql-formatter';
|
||||
import { AutoChart, BackEndChartType, getChartType } from '@/components/chart/autoChart';
|
||||
import { CodePreview } from './code-preview';
|
||||
import { formatSql } from '@/utils';
|
||||
|
||||
function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType; sql: string }) {
|
||||
const columns = data?.[0]
|
||||
@@ -20,10 +20,11 @@ function ChartView({ data, type, sql }: { data: Datum[]; type: BackEndChartType;
|
||||
label: 'Chart',
|
||||
children: <AutoChart data={data} chartType={getChartType(type)} />,
|
||||
};
|
||||
|
||||
const SqlItem = {
|
||||
key: 'sql',
|
||||
label: 'SQL',
|
||||
children: <CodePreview language="sql" code={format(sql ?? '', { language: 'mysql' }) as string} />,
|
||||
children: <CodePreview language="sql" code={formatSql(sql)} />,
|
||||
};
|
||||
const DataItem = {
|
||||
key: 'data',
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { LinkOutlined, ReadOutlined, SyncOutlined } from '@ant-design/icons';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { Table, Image, Tag, Tabs, TabsProps, Popover } from 'antd';
|
||||
import { format } from 'sql-formatter';
|
||||
import { Reference } from '@/types/chat';
|
||||
import { AutoChart, BackEndChartType, getChartType } from '@/components/chart';
|
||||
import { CodePreview } from './code-preview';
|
||||
@@ -15,6 +14,7 @@ import VisChart from './vis-chart';
|
||||
import VisDashboard from './vis-dashboard';
|
||||
import VisPlugin from './vis-plugin';
|
||||
import VisCode from './vis-code';
|
||||
import { formatSql } from '@/utils';
|
||||
|
||||
type MarkdownComponent = Parameters<typeof ReactMarkdown>['0']['components'];
|
||||
|
||||
@@ -228,7 +228,7 @@ const extraComponents: MarkdownComponent = {
|
||||
const SqlItem = {
|
||||
key: 'sql',
|
||||
label: 'SQL',
|
||||
children: <CodePreview code={format(data?.sql, { language: 'mysql' }) as string} language={'sql'} />,
|
||||
children: <CodePreview code={formatSql(data?.sql, 'mysql')} language="sql" />,
|
||||
};
|
||||
const DataItem = {
|
||||
key: 'data',
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { format } from 'sql-formatter';
|
||||
import { CodePreview } from './code-preview';
|
||||
import { formatSql } from '@/utils';
|
||||
|
||||
interface Props {
|
||||
data: {
|
||||
@@ -15,7 +15,7 @@ function VisConvertError({ data }: Props) {
|
||||
<div className="p-3 text-white bg-red-500 whitespace-normal">{data.display_type}</div>
|
||||
<div className="p-3 bg-red-50">
|
||||
<div className="mb-2 whitespace-normal">{data.thought}</div>
|
||||
<CodePreview code={format(data.sql)} language="sql" />
|
||||
<CodePreview code={formatSql(data.sql)} language="sql" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user