Skip to content

Commit b6d9f84

Browse files
committed
merge
2 parents 39f45d7 + bf94248 commit b6d9f84

File tree

7 files changed

+61
-37
lines changed

7 files changed

+61
-37
lines changed

.github/workflows/release.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ jobs:
255255
cp chat2db-client/versions/${{ steps.chat2db_version.outputs.substring }}/static/chat2db-server-start.jar ./oss_temp_file
256256
cp -r chat2db-client/release/*.dmg ./oss_temp_file
257257
cp -r chat2db-client/versions/${{ steps.chat2db_version.outputs.substring }}/dist ./oss_temp_file/dist
258-
cd chat2db-client/versions/${{ steps.chat2db_version.outputs.substring }}/static/ && zip -r chat2db-server-start.zip ./
258+
cd chat2db-client/versions/${{ steps.chat2db_version.outputs.substring }}/ && zip -r ${{ steps.chat2db_version.outputs.substring }}.zip ./
259+
cp -r ${{ steps.chat2db_version.outputs.substring }}.zip ../../../oss_temp_file
260+
cd static/ && zip -r chat2db-server-start.zip ./
259261
cp -r chat2db-server-start.zip ../../../../oss_temp_file
260262
261263
# 准备要需要的数据 MacOS arm64

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

+22-24
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
135135
editorRef: editorRef?.current,
136136
}));
137137

138-
useEffect(() => {}, []);
139-
140138
useEffect(() => {
141139
if (source !== 'workspace') {
142140
return;
@@ -153,20 +151,20 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
153151
} else {
154152
// 活跃时自动保存
155153
indexedDB
156-
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
157-
consoleId: executeParams.consoleId!,
158-
userId: getCookie('CHAT2DB.USER_ID'),
159-
})
160-
.then((res: any) => {
161-
const value = defaultValue || res?.[0]?.ddl || '';
162-
const oldValue = editorRef?.current?.getAllContent();
163-
if(value !== oldValue){
164-
editorRef?.current?.setValue(value, 'reset');
165-
}
166-
setTimeout(() => {
167-
timingAutoSave();
168-
}, 0);
169-
});
154+
.getDataByCursor('chat2db', 'workspaceConsoleDDL', {
155+
consoleId: executeParams.consoleId!,
156+
userId: getCookie('CHAT2DB.USER_ID'),
157+
})
158+
.then((res: any) => {
159+
const value = defaultValue || res?.[0]?.ddl || '';
160+
const oldValue = editorRef?.current?.getAllContent();
161+
if (value !== oldValue) {
162+
editorRef?.current?.setValue(value, 'reset');
163+
}
164+
setTimeout(() => {
165+
timingAutoSave();
166+
}, 0);
167+
});
170168
}
171169
return () => {
172170
if (timerRef.current) {
@@ -180,18 +178,18 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
180178
clearInterval(timerRef.current);
181179
}
182180
timerRef.current = setInterval(() => {
183-
const ddl = editorRef?.current?.getAllContent()
184-
if(ddl === lastSyncConsole.current){
185-
return
181+
const ddl = editorRef?.current?.getAllContent();
182+
if (ddl === lastSyncConsole.current) {
183+
return;
186184
}
187185
lastSyncConsole.current = ddl;
188-
if(executeParams.status === ConsoleStatus.RELEASE || status === ConsoleStatus.RELEASE){
186+
if (executeParams.status === ConsoleStatus.RELEASE || status === ConsoleStatus.RELEASE) {
189187
const p: any = {
190188
id: executeParams.consoleId,
191189
ddl,
192190
};
193-
historyServer.updateSavedConsole(p)
194-
}else{
191+
historyServer.updateSavedConsole(p);
192+
} else {
195193
indexedDB.updateData('chat2db', 'workspaceConsoleDDL', {
196194
consoleId: executeParams.consoleId!,
197195
ddl,
@@ -466,10 +464,10 @@ function Console(props: IProps, ref: ForwardedRef<IConsoleRef>) {
466464
};
467465

468466
const handleSelectTableSyncModel = () => {
469-
const syncModel: SyncModelType | null = Number(localStorage.getItem('syncTableModel')) ?? null;
467+
const syncModel = localStorage.getItem('syncTableModel');
470468
const hasAiAccess = aiModel.hasWhite;
471469
if (syncModel !== null) {
472-
setSyncTableModel(syncModel);
470+
setSyncTableModel(Number(syncModel));
473471
return;
474472
}
475473

chat2db-server/chat2db-plugins/chat2db-h2/src/main/java/ai/chat2db/plugin/h2/H2DBManage.java

+19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
package ai.chat2db.plugin.h2;
22

33
import java.sql.Connection;
4+
import java.sql.SQLException;
45

56
import ai.chat2db.spi.DBManage;
67
import ai.chat2db.spi.jdbc.DefaultDBManage;
8+
import ai.chat2db.spi.sql.Chat2DBContext;
9+
import ai.chat2db.spi.sql.ConnectInfo;
710
import ai.chat2db.spi.sql.SQLExecutor;
11+
import org.apache.commons.lang3.ObjectUtils;
12+
import org.apache.commons.lang3.StringUtils;
813

914
public class H2DBManage extends DefaultDBManage implements DBManage {
1015

16+
@Override
17+
public void connectDatabase(Connection connection, String database) {
18+
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
19+
if (ObjectUtils.anyNull(connectInfo) || StringUtils.isEmpty(connectInfo.getSchemaName())) {
20+
return;
21+
}
22+
String schemaName = connectInfo.getSchemaName();
23+
try {
24+
SQLExecutor.getInstance().execute(connection, "SET SCHEMA \"" + schemaName + "\"");
25+
} catch (SQLException e) {
26+
27+
}
28+
}
29+
1130

1231
@Override
1332
public void dropTable(Connection connection, String databaseName, String schemaName, String tableName) {

chat2db-server/chat2db-plugins/chat2db-postgresql/src/main/java/ai/chat2db/plugin/postgresql/PostgreSQLDBManage.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44

55
import ai.chat2db.spi.DBManage;
66
import ai.chat2db.spi.jdbc.DefaultDBManage;
7+
import ai.chat2db.spi.sql.Chat2DBContext;
78
import ai.chat2db.spi.sql.ConnectInfo;
89
import ai.chat2db.spi.sql.SQLExecutor;
10+
import org.apache.commons.lang3.StringUtils;
911

1012
public class PostgreSQLDBManage extends DefaultDBManage implements DBManage {
1113
@Override
1214
public void connectDatabase(Connection connection, String database) {
13-
//try {
14-
// SQLExecutor.getInstance().execute(connection,"SELECT pg_database_size('"+database+"');");
15-
//} catch (SQLException e) {
16-
// throw new RuntimeException(e);
17-
//}
15+
try {
16+
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
17+
if (!StringUtils.isEmpty(connectInfo.getSchemaName())) {
18+
SQLExecutor.getInstance().execute(connection, "SET search_path TO \"" + connectInfo.getSchemaName() + "\"");
19+
}
20+
} catch (Exception e) {
21+
22+
}
1823
}
1924

2025
@Override
@@ -26,7 +31,7 @@ public Connection getConnection(ConnectInfo connectInfo) {
2631
}
2732
connectInfo.setUrl(url);
2833

29-
return super.getConnection(connectInfo);
34+
return super.getConnection(connectInfo);
3035
}
3136

3237

@@ -53,8 +58,8 @@ public String replaceDatabaseInJdbcUrl(String url, String newDatabase) {
5358

5459
@Override
5560
public void dropTable(Connection connection, String databaseName, String schemaName, String tableName) {
56-
String sql = "DROP TABLE "+ tableName;
57-
SQLExecutor.getInstance().executeSql(connection,sql, resultSet -> null);
61+
String sql = "DROP TABLE " + tableName;
62+
SQLExecutor.getInstance().executeSql(connection, sql, resultSet -> null);
5863
}
5964

6065
}

chat2db-server/chat2db-plugins/chat2db-sqlserver/src/main/java/ai/chat2db/plugin/sqlserver/SqlServerDBManage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SqlServerDBManage extends DefaultDBManage implements DBManage {
1111
@Override
1212
public void connectDatabase(Connection connection, String database) {
1313
try {
14-
SQLExecutor.getInstance().execute(connection,"use [" + database + "];");
14+
SQLExecutor.getInstance().execute(connection, "use [" + database + "];");
1515
} catch (SQLException e) {
1616
throw new RuntimeException(e);
1717
}

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/RdbDmlController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public DataResult<ExecuteResultVO> executeDDL(@RequestBody DmlRequest request) {
9393
try {
9494
boolean flag = true;
9595
ExecuteResultVO executeResult = null;
96-
connection.setAutoCommit(false);
96+
//connection.setAutoCommit(false);
9797
ListResult<ExecuteResult> resultDTOListResult = dlTemplateService.execute(param);
9898
List<ExecuteResultVO> resultVOS = rdbWebConverter.dto2vo(resultDTOListResult.getData());
9999
if (!CollectionUtils.isEmpty(resultVOS)) {
@@ -107,7 +107,7 @@ public DataResult<ExecuteResultVO> executeDDL(@RequestBody DmlRequest request) {
107107
}
108108
}
109109
if (flag) {
110-
connection.commit();
110+
//connection.commit();
111111
return DataResult.of(resultVOS.get(0));
112112
}else {
113113
connection.rollback();

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/rdb/doc/DatabaseExportService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void generate(String databaseName, OutputStream outputStream, ExportOptio
108108
try {
109109
export(outputStream, exportOptions);
110110
} catch (Exception e) {
111-
throw new RuntimeException("导出失败!请联系开发者,邮箱:[email protected]" + e);
111+
throw new RuntimeException("导出失败!请联系开发者" + e);
112112
}
113113
init();
114114
}

0 commit comments

Comments
 (0)