mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Revert "Nested Folders: Fix fetching a folder by title" (#76469)
Revert "Nested Folders: Fix fetching a folder by title (#74725)"
This reverts commit 0eac9aff7f.
This commit is contained in:
committed by
GitHub
parent
29cf60988b
commit
bdeb829cf6
@@ -166,15 +166,7 @@ func (ss *sqlStore) Get(ctx context.Context, q folder.GetFolderQuery) (*folder.F
|
||||
case q.ID != nil:
|
||||
exists, err = sess.SQL("SELECT * FROM folder WHERE id = ?", q.ID).Get(foldr)
|
||||
case q.Title != nil:
|
||||
args := []any{*q.Title, q.OrgID}
|
||||
s := "SELECT * FROM folder WHERE title = ? AND org_id = ?"
|
||||
if q.ParentUID != nil {
|
||||
s = s + " AND parent_uid = ?"
|
||||
args = append(args, *q.ParentUID)
|
||||
} else {
|
||||
s = s + " AND parent_uid IS NULL"
|
||||
}
|
||||
exists, err = sess.SQL(s, args...).Get(foldr)
|
||||
exists, err = sess.SQL("SELECT * FROM folder WHERE title = ? AND org_id = ?", q.Title, q.OrgID).Get(foldr)
|
||||
default:
|
||||
return folder.ErrBadRequest.Errorf("one of ID, UID, or Title must be included in the command")
|
||||
}
|
||||
|
||||
@@ -384,17 +384,6 @@ func TestIntegrationGet(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// create subfolder with same title
|
||||
subfolderUID := util.GenerateShortUID()
|
||||
subfolder, err := folderStore.Create(context.Background(), folder.CreateFolderCommand{
|
||||
Title: folderTitle,
|
||||
Description: folderDsc,
|
||||
OrgID: orgID,
|
||||
UID: subfolderUID,
|
||||
ParentUID: f.UID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
err := folderStore.Delete(context.Background(), f.UID, orgID)
|
||||
require.NoError(t, err)
|
||||
@@ -416,14 +405,15 @@ func TestIntegrationGet(t *testing.T) {
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
assert.Equal(t, f.Title, ff.Title)
|
||||
assert.Equal(t, f.Description, ff.Description)
|
||||
//assert.Equal(t, folder.GeneralFolderUID, ff.ParentUID)
|
||||
assert.NotEmpty(t, ff.Created)
|
||||
assert.NotEmpty(t, ff.Updated)
|
||||
assert.NotEmpty(t, ff.URL)
|
||||
})
|
||||
|
||||
t.Run("get folder by title should return folder under root", func(t *testing.T) {
|
||||
t.Run("get folder by title should succeed", func(t *testing.T) {
|
||||
ff, err := folderStore.Get(context.Background(), folder.GetFolderQuery{
|
||||
Title: &folderTitle,
|
||||
Title: &f.Title,
|
||||
OrgID: orgID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@@ -432,30 +422,13 @@ func TestIntegrationGet(t *testing.T) {
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
assert.Equal(t, f.Title, ff.Title)
|
||||
assert.Equal(t, f.Description, ff.Description)
|
||||
//assert.Equal(t, folder.GeneralFolderUID, ff.ParentUID)
|
||||
assert.NotEmpty(t, ff.Created)
|
||||
assert.NotEmpty(t, ff.Updated)
|
||||
assert.NotEmpty(t, ff.URL)
|
||||
})
|
||||
|
||||
t.Run("get folder by title and parent UID should return subfolder", func(t *testing.T) {
|
||||
ff, err := folderStore.Get(context.Background(), folder.GetFolderQuery{
|
||||
Title: &folderTitle,
|
||||
OrgID: orgID,
|
||||
ParentUID: &f.UID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, subfolder.ID, ff.ID)
|
||||
assert.Equal(t, subfolder.UID, ff.UID)
|
||||
assert.Equal(t, subfolder.OrgID, ff.OrgID)
|
||||
assert.Equal(t, subfolder.Title, ff.Title)
|
||||
assert.Equal(t, subfolder.Description, ff.Description)
|
||||
assert.Equal(t, subfolder.ParentUID, ff.ParentUID)
|
||||
assert.NotEmpty(t, subfolder.Created)
|
||||
assert.NotEmpty(t, subfolder.Updated)
|
||||
assert.NotEmpty(t, subfolder.URL)
|
||||
})
|
||||
|
||||
t.Run("get folder by ID should succeed", func(t *testing.T) {
|
||||
t.Run("get folder by title should succeed", func(t *testing.T) {
|
||||
ff, err := folderStore.Get(context.Background(), folder.GetFolderQuery{
|
||||
ID: &f.ID,
|
||||
})
|
||||
@@ -465,6 +438,7 @@ func TestIntegrationGet(t *testing.T) {
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
assert.Equal(t, f.Title, ff.Title)
|
||||
assert.Equal(t, f.Description, ff.Description)
|
||||
//assert.Equal(t, folder.GeneralFolderUID, ff.ParentUID)
|
||||
assert.NotEmpty(t, ff.Created)
|
||||
assert.NotEmpty(t, ff.Updated)
|
||||
assert.NotEmpty(t, ff.URL)
|
||||
|
||||
Reference in New Issue
Block a user