Skip to content

Commit 1d6034f

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents cdd743a + af603c2 commit 1d6034f

18 files changed

Lines changed: 373 additions & 300 deletions

File tree

chat2db-client/.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"Mddhhmmss",
5656
"Menlo",
5757
"netstat",
58+
"NOCASE",
5859
"nsis",
5960
"OCEANBASE",
6061
"OPENAI",
@@ -67,6 +68,7 @@
6768
"Prec",
6869
"remaininguses",
6970
"RESTAI",
71+
"RTRIM",
7072
"scrollbar",
7173
"Sercurity",
7274
"sortablejs",

chat2db-client/src/blocks/DatabaseTableEditor/BaseInfo/index.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import classnames from 'classnames';
44
import { Form, Input } from 'antd';
55
import { Context } from '../index';
66
import { IBaseInfo } from '@/typings';
7+
import { DatabaseTypeCode } from '@/constants';
78
import i18n from '@/i18n';
89

910
export interface IBaseInfoRef {
@@ -16,7 +17,7 @@ interface IProps {
1617

1718
const BaseInfo = forwardRef((props: IProps, ref: ForwardedRef<IBaseInfoRef>) => {
1819
const { className } = props;
19-
const { tableDetails } = useContext(Context);
20+
const { tableDetails, databaseType } = useContext(Context);
2021
const [form] = Form.useForm();
2122

2223
useEffect(() => {
@@ -53,15 +54,19 @@ const BaseInfo = forwardRef((props: IProps, ref: ForwardedRef<IBaseInfoRef>) =>
5354
<Form.Item label={`${i18n('editTable.label.comment')}:`} name="comment">
5455
<Input autoComplete="off" />
5556
</Form.Item>
56-
<Form.Item label={`${i18n('editTable.label.characterSet')}:`} name="charset">
57-
<Input autoComplete="off" />
58-
</Form.Item>
59-
<Form.Item label={`${i18n('editTable.label.engine')}:`} name="engine">
60-
<Input autoComplete="off" />
61-
</Form.Item>
62-
<Form.Item label={`${i18n('editTable.label.incrementValue')}:`} name="incrementValue">
63-
<Input autoComplete="off" />
64-
</Form.Item>
57+
{databaseType === DatabaseTypeCode.MYSQL && (
58+
<>
59+
<Form.Item label={`${i18n('editTable.label.characterSet')}:`} name="charset">
60+
<Input autoComplete="off" />
61+
</Form.Item>
62+
<Form.Item label={`${i18n('editTable.label.engine')}:`} name="engine">
63+
<Input autoComplete="off" />
64+
</Form.Item>
65+
<Form.Item label={`${i18n('editTable.label.incrementValue')}:`} name="incrementValue">
66+
<Input autoComplete="off" />
67+
</Form.Item>
68+
</>
69+
)}
6570
</Form>
6671
</div>
6772
</div>

chat2db-client/src/blocks/DatabaseTableEditor/ColumnList/index.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CSS } from '@dnd-kit/utilities';
1010
import { Context } from '../index';
1111
import { IColumnItemNew, IColumnTypes } from '@/typings';
1212
import i18n from '@/i18n';
13-
import { EditColumnOperationType } from '@/constants';
13+
import { EditColumnOperationType, DatabaseTypeCode } from '@/constants';
1414
import CustomSelect from '@/components/CustomSelect';
1515
import Iconfont from '@/components/Iconfont';
1616

@@ -93,7 +93,7 @@ const createInitialData = () => {
9393
};
9494

9595
const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>) => {
96-
const { databaseSupportField, databaseName, schemaName, tableDetails } = useContext(Context);
96+
const { databaseSupportField, databaseName, schemaName, tableDetails, databaseType } = useContext(Context);
9797
const [dataSource, setDataSource] = useState<IColumnItemNew[]>([createInitialData()]);
9898
const [form] = Form.useForm();
9999
const [editingData, setEditingData] = useState<IColumnItemNew | null>(null);
@@ -246,6 +246,10 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
246246
{
247247
width: '40px',
248248
render: (text: string, record: IColumnItemNew) => {
249+
// sqlLite不支持删除字段,新增的字段可以删除
250+
if (databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add) {
251+
return null;
252+
}
249253
return (
250254
<div
251255
className={styles.operationBar}
@@ -384,6 +388,11 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
384388
<Checkbox />
385389
</Form.Item>
386390
)}
391+
{databaseType === DatabaseTypeCode.SQLSERVER && (
392+
<Form.Item labelCol={labelCol} label={i18n('editTable.label.sparse')} name="sparse" valuePropName="checked">
393+
<Checkbox />
394+
</Form.Item>
395+
)}
387396
{editingConfig?.supportDefaultValue && (
388397
<Form.Item labelCol={labelCol} label={i18n('editTable.label.defaultValue')} name="defaultValue">
389398
<CustomSelect
@@ -415,6 +424,17 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
415424
<Input autoComplete="off" />
416425
</Form.Item>
417426
)}
427+
{editingConfig?.supportUnit && (
428+
<Form.Item labelCol={labelCol} label={i18n('editTable.label.unit')} name="unit">
429+
<Select style={{ width: '100%' }}>
430+
{['CHAR', 'BYTE'].map((i) => (
431+
<Select.Option key={i} value={i}>
432+
{i}
433+
</Select.Option>
434+
))}
435+
</Select>
436+
</Form.Item>
437+
)}
418438
{editingConfig?.supportValue && (
419439
<Form.Item labelCol={labelCol} label={i18n('editTable.label.value')} name="value">
420440
<Input autoComplete="off" />
@@ -427,6 +447,10 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
427447
const onRow = (record: any) => {
428448
return {
429449
onClick: () => {
450+
// sqlLite不支持修改字段,新增的字段可以修改
451+
if (databaseType === DatabaseTypeCode.SQLITE && record.editStatus !== EditColumnOperationType.Add) {
452+
return;
453+
}
430454
if (editingData?.key !== record.key) {
431455
edit(record);
432456
}

chat2db-client/src/blocks/DatabaseTableEditor/IncludeCol/index.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Table, Form, Select, Button } from 'antd';
1717
import { v4 as uuidv4 } from 'uuid';
1818
import { Context } from '../index';
1919
import { IColumnItemNew, IIndexIncludeColumnItem } from '@/typings';
20+
import { DatabaseTypeCode } from '@/constants';
2021
import i18n from '@/i18n';
2122
import lodash from 'lodash';
2223
import Iconfont from '@/components/Iconfont';
@@ -53,7 +54,7 @@ export interface IIncludeColRef {
5354

5455
const IncludeCol = forwardRef((props: IProps, ref: ForwardedRef<IIncludeColRef>) => {
5556
const { includedColumnList } = props;
56-
const { columnListRef } = useContext(Context);
57+
const { columnListRef, databaseType } = useContext(Context);
5758
const [dataSource, setDataSource] = useState<IIndexIncludeColumnItem[]>([createInitialData()]);
5859
const [form] = Form.useForm();
5960
const [editingKey, setEditingKey] = useState<string | null>(null);
@@ -181,6 +182,31 @@ const IncludeCol = forwardRef((props: IProps, ref: ForwardedRef<IIncludeColRef>)
181182
// },
182183
// },
183184
];
185+
// sqlLite 添加排序规则
186+
if (databaseType === DatabaseTypeCode.SQLITE) {
187+
columns.splice(2, 0, {
188+
title: i18n('editTable.label.collation'),
189+
dataIndex: 'collation',
190+
render: (text: string, record: IIndexIncludeColumnItem) => {
191+
const editable = isEditing(record);
192+
return editable ? (
193+
<Form.Item name="collation" style={{ margin: 0 }}>
194+
<Select
195+
options={[
196+
{ label: 'BINARY', value: 'BINARY' },
197+
{ label: 'NOCASE', value: 'NOCASE' },
198+
{ label: 'RTRIM', value: 'RTRIM' },
199+
]}
200+
/>
201+
</Form.Item>
202+
) : (
203+
<div className={styles.editableCell} onClick={() => edit(record)}>
204+
{text}
205+
</div>
206+
);
207+
},
208+
});
209+
}
184210

185211
const handelFieldsChange = (field: any) => {
186212
const { value } = field[0];

0 commit comments

Comments
 (0)