Skip to content

Commit

Permalink
Merge pull request #10 from calebx/main
Browse files Browse the repository at this point in the history
change lft to rgt
  • Loading branch information
griffinqiu authored Dec 24, 2020
2 parents 0e4c01f + 666af14 commit 57a86d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ require (
github.com/bluele/factory-go v0.0.0-20200430111232-df9c4ffc2e3e
github.com/stretchr/testify v1.5.1
gorm.io/driver/postgres v0.2.7
gorm.io/gorm v0.2.34
gorm.io/gorm v1.20.8
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gorm.io/driver/postgres v0.2.7 h1:fj27ZhXPFUdMVdRijQJm/Hjv6qrWYbGb1z33KhVis0w=
gorm.io/driver/postgres v0.2.7/go.mod h1:KTcwwmyZ5KlzuFaHmHkwCMfOhqr+7ZPq8cRR3LJzv0Y=
gorm.io/gorm v0.2.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v0.2.34 h1:EoAchqG2br01vuxJw6B4ED235irbL9WVhdBUmLUml4c=
gorm.io/gorm v0.2.34/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.8 h1:iToaOdZgjNvlc44NFkxfLa3U9q63qwaxt0FdNCiwOMs=
gorm.io/gorm v1.20.8/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
6 changes: 3 additions & 3 deletions nested_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func parseNode(db *gorm.DB, source interface{}) (tx *gorm.DB, item nodeItem, err

// MoveTo move node to a position which is related a target node
func MoveTo(db *gorm.DB, node, to interface{}, direction MoveDirection) error {
tx, targetNode, err := parseNode(db, node)
_, targetNode, err := parseNode(db, node)
if err != nil {
return err
}
Expand All @@ -108,7 +108,7 @@ func MoveTo(db *gorm.DB, node, to interface{}, direction MoveDirection) error {
return err
}

tx = tx.Table(targetNode.TableName)
tx := db.Table(targetNode.TableName)

var right, depthChange int
var newParentID sql.NullInt64
Expand Down Expand Up @@ -137,7 +137,7 @@ func moveToRightOfPosition(tx *gorm.DB, targetNode nodeItem, position, depthChan
targetWidth := targetRight - targetLeft + 1

targetIds := []int64{}
err = tx.Where(formatSQL(":rgt >= ? AND :rgt <= ?", targetNode), targetLeft, targetRight).Pluck("id", &targetIds).Error
err = tx.Where(formatSQL(":lft >= ? AND :rgt <= ?", targetNode), targetLeft, targetRight).Pluck("id", &targetIds).Error
if err != nil {
return
}
Expand Down

0 comments on commit 57a86d3

Please sign in to comment.