mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Data layer restructuring (#997)
* Move query builders to sqlite package * Add transaction system * Wrap model resolvers in transaction * Add error return value for StringSliceToIntSlice * Update/refactor mutation resolvers * Convert query builders * Remove unused join types * Add stash id unit tests * Use WAL journal mode
This commit is contained in:
@@ -4,18 +4,16 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
func ValidateModifyStudio(studio models.StudioPartial, tx *sqlx.Tx) error {
|
||||
func ValidateModifyStudio(studio models.StudioPartial, qb models.StudioReader) error {
|
||||
if studio.ParentID == nil || !studio.ParentID.Valid {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ensure there is no cyclic dependency
|
||||
thisID := studio.ID
|
||||
qb := models.NewStudioQueryBuilder()
|
||||
|
||||
currentParentID := *studio.ParentID
|
||||
|
||||
@@ -24,7 +22,7 @@ func ValidateModifyStudio(studio models.StudioPartial, tx *sqlx.Tx) error {
|
||||
return errors.New("studio cannot be an ancestor of itself")
|
||||
}
|
||||
|
||||
currentStudio, err := qb.Find(int(currentParentID.Int64), tx)
|
||||
currentStudio, err := qb.Find(int(currentParentID.Int64))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error finding parent studio: %s", err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user