Skip to content

Commit 2db1a2e

Browse files
authored
Merge pull request #828 from chat2db/dev
Dev
2 parents ef2e87e + 429774c commit 2db1a2e

File tree

32 files changed

+396
-73
lines changed

32 files changed

+396
-73
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 3.0.13
2+
3+
`2023-11-15`
4+
5+
**Changelog**
6+
7+
- 🐞【Fixed】oracle datatype error
8+
- 🐞【Fixed】DM index error
9+
10+
111
## 3.0.12
212

313
`2023-11-13`

CHANGELOG_CN.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 3.0.13
2+
3+
`2023-11-15`
4+
5+
**更新日志**
6+
7+
- 🐞【修复】oracle datatype 错误
8+
- 🐞【修复】DM index 错误
9+
110
## 3.0.12
211

312
`2023-11-13`

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -503,18 +503,7 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
503503
)}
504504
{editingConfig?.supportDefaultValue && (
505505
<Form.Item labelCol={labelCol} label={i18n('editTable.label.defaultValue')} name="defaultValue">
506-
<CustomSelect
507-
options={[
508-
{
509-
label: 'EMPTY_STRING',
510-
value: 'EMPTY_STRING',
511-
},
512-
{
513-
label: 'NULL',
514-
value: 'NULL',
515-
},
516-
]}
517-
/>
506+
<CustomSelect options={databaseSupportField.defaultValues} />
518507
</Form.Item>
519508
)}
520509
{editingConfig?.supportCharset && (

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface IDatabaseSupportField {
5454
charsets: IOption[];
5555
collations: IOption[];
5656
indexTypes: IOption[];
57+
defaultValues: IOption[];
5758
}
5859

5960
export default memo((props: IProps) => {
@@ -93,6 +94,7 @@ export default memo((props: IProps) => {
9394
charsets: [],
9495
collations: [],
9596
indexTypes: [],
97+
defaultValues: [],
9698
});
9799
const [isLoading, setIsLoading] = useState<boolean>(false);
98100

@@ -148,11 +150,20 @@ export default memo((props: IProps) => {
148150
};
149151
}) || [];
150152

153+
const defaultValues =
154+
res?.defaultValues?.map((i) => {
155+
return {
156+
value: i.defaultValue,
157+
label: i.defaultValue,
158+
};
159+
}) || [];
160+
151161
setDatabaseSupportField({
152162
columnTypes,
153163
charsets,
154164
collations,
155165
indexTypes,
166+
defaultValues,
156167
});
157168
});
158169
}

chat2db-client/src/components/Console/index.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
406406
const handleError = (error: any) => {
407407
console.error('Error:', error);
408408
setIsLoading(false);
409+
setIsAiDrawerLoading(false);
409410
setIsStream(false);
410411
closeEventSource.current();
411412
};
@@ -576,7 +577,21 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
576577

577578
{/* <NewEditor id={uid} dataSource={props.executeParams.type} database={props.executeParams.databaseName} /> */}
578579

579-
<Drawer open={isAiDrawerOpen} getContainer={false} mask={false} onClose={() => setIsAiDrawerOpen(false)}>
580+
<Drawer
581+
open={isAiDrawerOpen}
582+
getContainer={false}
583+
mask={false}
584+
onClose={() => {
585+
try {
586+
setIsAiDrawerOpen(false);
587+
setIsAiDrawerLoading(false);
588+
setIsStream(false);
589+
closeEventSource.current && closeEventSource.current();
590+
} catch (error) {
591+
console.log('close drawer', error);
592+
}
593+
}}
594+
>
580595
<Spin spinning={isAiDrawerLoading} style={{ height: '100%' }}>
581596
<div className={styles.aiBlock}>{aiContent}</div>
582597
</Spin>

chat2db-client/src/typings/database.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface IDatabaseSupportField {
5151
charsets: ICharset[];
5252
collations: ICollation[];
5353
indexTypes: IIndexTypes[];
54+
defaultValues: IDefaultValue[];
5455
}
5556

5657
/** 字段所对应的 字符集*/
@@ -84,3 +85,8 @@ export interface IColumnTypes {
8485
supportValue: boolean; // 是否支持值
8586
supportUnit: boolean; // 是否支持单位
8687
}
88+
89+
/** 不同数据库支持不同的默认值 */
90+
export interface IDefaultValue {
91+
defaultValue: string; // 默认值
92+
}

chat2db-server/chat2db-plugins/chat2db-db2/src/main/java/ai/chat2db/plugin/db2/DB2MetaData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import ai.chat2db.plugin.db2.builder.DB2SqlBuilder;
1010
import ai.chat2db.plugin.db2.type.DB2ColumnTypeEnum;
11+
import ai.chat2db.plugin.db2.type.DB2DefaultValueEnum;
1112
import ai.chat2db.plugin.db2.type.DB2IndexTypeEnum;
1213
import ai.chat2db.spi.MetaData;
1314
import ai.chat2db.spi.SqlBuilder;
@@ -152,6 +153,7 @@ public TableMeta getTableMeta(String databaseName, String schemaName, String tab
152153
.charsets(Lists.newArrayList())
153154
.collations(Lists.newArrayList())
154155
.indexTypes(DB2IndexTypeEnum.getIndexTypes())
156+
.defaultValues(DB2DefaultValueEnum.getDefaultValues())
155157
.build();
156158
}
157159

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ai.chat2db.plugin.db2.type;
2+
3+
import ai.chat2db.spi.model.DefaultValue;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
public enum DB2DefaultValueEnum {
9+
EMPTY_STRING("EMPTY_STRING"),
10+
NULL("NULL"),
11+
;
12+
private DefaultValue defaultValue;
13+
14+
DB2DefaultValueEnum(String defaultValue) {
15+
this.defaultValue = new DefaultValue(defaultValue);
16+
}
17+
18+
19+
public DefaultValue getDefaultValue() {
20+
return defaultValue;
21+
}
22+
23+
public static List<DefaultValue> getDefaultValues() {
24+
return Arrays.stream(DB2DefaultValueEnum.values()).map(DB2DefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
25+
}
26+
27+
}

chat2db-server/chat2db-plugins/chat2db-dm/src/main/java/ai/chat2db/plugin/dm/DMMetaData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import ai.chat2db.plugin.dm.builder.DMSqlBuilder;
1010
import ai.chat2db.plugin.dm.type.DMColumnTypeEnum;
11+
import ai.chat2db.plugin.dm.type.DMDefaultValueEnum;
1112
import ai.chat2db.plugin.dm.type.DMIndexTypeEnum;
1213
import ai.chat2db.spi.MetaData;
1314
import ai.chat2db.spi.SqlBuilder;
@@ -218,6 +219,7 @@ public TableMeta getTableMeta(String databaseName, String schemaName, String tab
218219
.charsets(Lists.newArrayList())
219220
.collations(Lists.newArrayList())
220221
.indexTypes(DMIndexTypeEnum.getIndexTypes())
222+
.defaultValues(DMDefaultValueEnum.getDefaultValues())
221223
.build();
222224
}
223225

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ai.chat2db.plugin.dm.type;
2+
3+
import ai.chat2db.spi.model.DefaultValue;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
public enum DMDefaultValueEnum {
9+
EMPTY_STRING("EMPTY_STRING"),
10+
NULL("NULL"),
11+
;
12+
private DefaultValue defaultValue;
13+
14+
DMDefaultValueEnum(String defaultValue) {
15+
this.defaultValue = new DefaultValue(defaultValue);
16+
}
17+
18+
19+
public DefaultValue getDefaultValue() {
20+
return defaultValue;
21+
}
22+
23+
public static List<DefaultValue> getDefaultValues() {
24+
return Arrays.stream(DMDefaultValueEnum.values()).map(DMDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
25+
}
26+
27+
}

0 commit comments

Comments
 (0)