mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
fix: new dataset can not update configuration (#16291)
This commit is contained in:
@@ -1512,7 +1512,7 @@ func (s *DatasetService) GetDataset(datasetID, userID string) (map[string]interf
|
||||
if err != nil {
|
||||
return nil, common.CodeServerError, errors.New("Database operation failed")
|
||||
}
|
||||
data["connectors"] = connectors
|
||||
data["connectors"] = datasetConnectorsOrEmpty(connectors)
|
||||
|
||||
return data, common.CodeSuccess, nil
|
||||
}
|
||||
@@ -1759,10 +1759,17 @@ func (s *DatasetService) UpdateDataset(datasetID, tenantID string, req UpdateDat
|
||||
if err != nil {
|
||||
return nil, common.CodeServerError, errors.New("Database operation failed")
|
||||
}
|
||||
data["connectors"] = linkedConnectors
|
||||
data["connectors"] = datasetConnectorsOrEmpty(linkedConnectors)
|
||||
return data, common.CodeSuccess, nil
|
||||
}
|
||||
|
||||
func datasetConnectorsOrEmpty(connectors []*dao.ConnectorDatasetListItem) []*dao.ConnectorDatasetListItem {
|
||||
if connectors == nil {
|
||||
return make([]*dao.ConnectorDatasetListItem, 0)
|
||||
}
|
||||
return connectors
|
||||
}
|
||||
|
||||
func datasetUpdateParserID(req UpdateDatasetRequest) (string, bool, error) {
|
||||
parserID := ""
|
||||
provided := false
|
||||
|
||||
@@ -115,6 +115,31 @@ func TestDatasetServiceUpdateDatasetUpdatesFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDatasetServiceGetDatasetReturnsEmptyConnectorList(t *testing.T) {
|
||||
db := setupDatasetUpdateTestDB(t)
|
||||
pushServiceDB(t, db)
|
||||
datasetID := "11111111111141118111111111111111"
|
||||
insertDatasetUpdateKB(t, datasetID, "tenant-1", "Original")
|
||||
|
||||
result, code, err := testDatasetUpdateService(t).GetDataset("11111111-1111-4111-8111-111111111111", "tenant-1")
|
||||
if err != nil {
|
||||
t.Fatalf("GetDataset failed: %v", err)
|
||||
}
|
||||
if code != common.CodeSuccess {
|
||||
t.Fatalf("expected success code, got %d", code)
|
||||
}
|
||||
connectors, ok := result["connectors"].([]*dao.ConnectorDatasetListItem)
|
||||
if !ok {
|
||||
t.Fatalf("expected connector list, got %#v", result["connectors"])
|
||||
}
|
||||
if connectors == nil {
|
||||
t.Fatal("expected empty connector list, got nil")
|
||||
}
|
||||
if len(connectors) != 0 {
|
||||
t.Fatalf("expected empty connector list, got %#v", connectors)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDatasetServiceUpdateDatasetRejectsMissingDataset(t *testing.T) {
|
||||
db := setupDatasetUpdateTestDB(t)
|
||||
pushServiceDB(t, db)
|
||||
@@ -313,6 +338,7 @@ func testDatasetUpdateService(t *testing.T) *DatasetService {
|
||||
|
||||
return &DatasetService{
|
||||
kbDAO: dao.NewKnowledgebaseDAO(),
|
||||
documentDAO: dao.NewDocumentDAO(),
|
||||
connectorDAO: dao.NewConnectorDAO(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user