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

build Delete() for delete a node and all its descendant #12

Merged
merged 11 commits into from
Dec 27, 2020

Conversation

calebx
Copy link
Contributor

@calebx calebx commented Dec 25, 2020

No description provided.

nested_set.go Outdated
if err != nil {
return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugly Gorm lock pattern. do you know how to lock a row without Find()?

nested_set.go Outdated
@@ -140,6 +147,7 @@ func Create(db *gorm.DB, source, parent interface{}) error {
return err
}

tx, _, _ := parseNode(db, source)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx should be refreshed after UPDATE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huacnlee @griffinqiu
any idea why?
Really confused me a lot.

nested_set.go Outdated
@@ -197,7 +252,7 @@ func MoveTo(db *gorm.DB, node, to interface{}, direction MoveDirection) error {
return err
}

tx = db.Table(targetNode.TableName)
tx = tx.Table(targetNode.TableName)
Copy link
Contributor Author

@calebx calebx Dec 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no db should be used after tx took after its scope

@huacnlee huacnlee merged commit 1033f63 into longbridgeapp:main Dec 27, 2020
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

Successfully merging this pull request may close these issues.

2 participants