mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Add related object filter criteria to various filter types in graphql schema (#4861)
* Move filter criterion handlers into separate file * Add related filters for image filter * Add related filters for scene filter * Add related filters to gallery filter * Add related filters to movie filter * Add related filters to performer filter * Add related filters to studio filter * Add related filters to tag filter * Add scene filter to scene marker filter
This commit is contained in:
@@ -35,7 +35,9 @@ func logSQL(start time.Time, query string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
type dbWrapper struct{}
|
||||
type dbWrapperType struct{}
|
||||
|
||||
var dbWrapper = dbWrapperType{}
|
||||
|
||||
func sqlError(err error, sql string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
@@ -45,7 +47,7 @@ func sqlError(err error, sql string, args ...interface{}) error {
|
||||
return fmt.Errorf("error executing `%s` [%v]: %w", sql, args, err)
|
||||
}
|
||||
|
||||
func (*dbWrapper) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
func (*dbWrapperType) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
tx, err := getDBReader(ctx)
|
||||
if err != nil {
|
||||
return sqlError(err, query, args...)
|
||||
@@ -58,7 +60,7 @@ func (*dbWrapper) Get(ctx context.Context, dest interface{}, query string, args
|
||||
return sqlError(err, query, args...)
|
||||
}
|
||||
|
||||
func (*dbWrapper) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
func (*dbWrapperType) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
|
||||
tx, err := getDBReader(ctx)
|
||||
if err != nil {
|
||||
return sqlError(err, query, args...)
|
||||
@@ -71,7 +73,7 @@ func (*dbWrapper) Select(ctx context.Context, dest interface{}, query string, ar
|
||||
return sqlError(err, query, args...)
|
||||
}
|
||||
|
||||
func (*dbWrapper) Queryx(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) {
|
||||
func (*dbWrapperType) Queryx(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) {
|
||||
tx, err := getDBReader(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, query, args...)
|
||||
@@ -84,7 +86,7 @@ func (*dbWrapper) Queryx(ctx context.Context, query string, args ...interface{})
|
||||
return ret, sqlError(err, query, args...)
|
||||
}
|
||||
|
||||
func (*dbWrapper) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) {
|
||||
func (*dbWrapperType) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) {
|
||||
tx, err := getDBReader(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, query, args...)
|
||||
@@ -97,7 +99,7 @@ func (*dbWrapper) QueryxContext(ctx context.Context, query string, args ...inter
|
||||
return ret, sqlError(err, query, args...)
|
||||
}
|
||||
|
||||
func (*dbWrapper) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error) {
|
||||
func (*dbWrapperType) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error) {
|
||||
tx, err := getTx(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, query, arg)
|
||||
@@ -110,7 +112,7 @@ func (*dbWrapper) NamedExec(ctx context.Context, query string, arg interface{})
|
||||
return ret, sqlError(err, query, arg)
|
||||
}
|
||||
|
||||
func (*dbWrapper) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (*dbWrapperType) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
tx, err := getTx(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, query, args...)
|
||||
@@ -124,7 +126,7 @@ func (*dbWrapper) Exec(ctx context.Context, query string, args ...interface{}) (
|
||||
}
|
||||
|
||||
// Prepare creates a prepared statement.
|
||||
func (*dbWrapper) Prepare(ctx context.Context, query string, args ...interface{}) (*stmt, error) {
|
||||
func (*dbWrapperType) Prepare(ctx context.Context, query string, args ...interface{}) (*stmt, error) {
|
||||
tx, err := getTx(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, query, args...)
|
||||
@@ -142,7 +144,7 @@ func (*dbWrapper) Prepare(ctx context.Context, query string, args ...interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (*dbWrapper) ExecStmt(ctx context.Context, stmt *stmt, args ...interface{}) (sql.Result, error) {
|
||||
func (*dbWrapperType) ExecStmt(ctx context.Context, stmt *stmt, args ...interface{}) (sql.Result, error) {
|
||||
_, err := getTx(ctx)
|
||||
if err != nil {
|
||||
return nil, sqlError(err, stmt.query, args...)
|
||||
|
||||
Reference in New Issue
Block a user