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:
WithoutPants
2021-01-18 12:23:20 +11:00
committed by GitHub
parent 7bae990c67
commit 1e04deb3d4
168 changed files with 12683 additions and 10863 deletions

View File

@@ -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())
}