feat(storage): read only transactions (#6417)

feat(storage): read only transactions for queries (#6415)

* fix: tests

* bastle wie en grosse

* fix(database): scan as callback

* fix tests

* fix merge failures

* remove as of system time

* refactor: remove unused test

* refacotr: remove unused lines
This commit is contained in:
Silvan
2023-08-22 14:49:02 +02:00
committed by GitHub
parent 7442492b8a
commit 22af4dcd97
128 changed files with 1355 additions and 897 deletions
+11 -9
View File
@@ -232,7 +232,7 @@ func addUserGrantWithoutOwnerRemoved(eq map[string]interface{}) {
addLoginNameWithoutOwnerRemoved(eq)
}
func (q *Queries) UserGrant(ctx context.Context, shouldTriggerBulk bool, withOwnerRemoved bool, queries ...SearchQuery) (_ *UserGrant, err error) {
func (q *Queries) UserGrant(ctx context.Context, shouldTriggerBulk bool, withOwnerRemoved bool, queries ...SearchQuery) (grant *UserGrant, err error) {
ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }()
@@ -253,11 +253,14 @@ func (q *Queries) UserGrant(ctx context.Context, shouldTriggerBulk bool, withOwn
return nil, errors.ThrowInternal(err, "QUERY-Fa1KW", "Errors.Query.SQLStatement")
}
row := q.client.QueryRowContext(ctx, stmt, args...)
return scan(row)
err = q.client.QueryRowContext(ctx, func(row *sql.Row) error {
grant, err = scan(row)
return err
}, stmt, args...)
return grant, err
}
func (q *Queries) UserGrants(ctx context.Context, queries *UserGrantsQueries, shouldTriggerBulk, withOwnerRemoved bool) (_ *UserGrants, err error) {
func (q *Queries) UserGrants(ctx context.Context, queries *UserGrantsQueries, shouldTriggerBulk, withOwnerRemoved bool) (grants *UserGrants, err error) {
ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }()
@@ -280,11 +283,10 @@ func (q *Queries) UserGrants(ctx context.Context, queries *UserGrantsQueries, sh
return nil, err
}
rows, err := q.client.QueryContext(ctx, stmt, args...)
if err != nil {
return nil, err
}
grants, err := scan(rows)
err = q.client.QueryContext(ctx, func(rows *sql.Rows) error {
grants, err = scan(rows)
return err
}, stmt, args...)
if err != nil {
return nil, err
}