fix: When agents use data tables, different users influence each other (#565)

This commit is contained in:
liuyunchao-1998
2025-08-06 16:03:21 +08:00
committed by GitHub
parent 8b91a640b9
commit 60285ca014
4 changed files with 302 additions and 1 deletions

View File

@@ -1075,7 +1075,16 @@ func (d databaseService) executeCustomSQL(ctx context.Context, req *ExecuteSQLRe
if err != nil {
return nil, fmt.Errorf("parse sql failed: %v", err)
}
// add rw mode
if tableInfo.RwMode == table.BotTableRWMode_LimitedReadWrite && len(req.UserID) != 0 {
switch operation {
case sqlparsercontract.OperationTypeSelect, sqlparsercontract.OperationTypeUpdate, sqlparsercontract.OperationTypeDelete:
parsedSQL, err = sqlparser.NewSQLParser().AppendSQLFilter(parsedSQL, sqlparsercontract.SQLFilterOpAnd, fmt.Sprintf("%s = '%s'", database.DefaultUidColName, req.UserID))
if err != nil {
return nil, fmt.Errorf("append sql filter failed: %v", err)
}
}
}
insertResult := make([]map[string]interface{}, 0)
if operation == sqlparsercontract.OperationTypeInsert {
cid := consts.CozeConnectorID