Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some bugs about group deletion #47

Open
Axkea opened this issue Nov 22, 2023 · 3 comments
Open

Some bugs about group deletion #47

Axkea opened this issue Nov 22, 2023 · 3 comments

Comments

@Axkea
Copy link

Axkea commented Nov 22, 2023

Looking at your logic about group deletion, you first find out all the child ids in a recursive way and delete them together. If there is a loop, it will SOF. you also didn't check when you added the group.A good approach is to remove the parent group before querying the child id

@Axkea
Copy link
Author

Axkea commented Nov 22, 2023

If it turns out to be a bug, I'll fix it

@Axkea
Copy link
Author

Axkea commented Nov 22, 2023

func getAllChildId(ctx *context.Context, rootId int) []int {
var ids []id
var ret []int
db.Instance.Select(&ids, db.WithContext(ctx, "select id from group where parent_id=? and user_id=?"), rootId, ctx.UserID)
for _, item := range ids {
ret = array.Merge(ret, getAllChildId(ctx, item.Id))
ret = append(ret, item.Id)
}
return ret
}

@Jinnrry
Copy link
Owner

Jinnrry commented Nov 22, 2023

yes,this is a bug,welcome pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants