Query policy (#411)

* entc/gen: drop xerrors package usage

* all: bump dependencies version

* entc/gen: adding query privacy policy support
This commit is contained in:
Alex Snast
2020-03-29 18:11:13 +03:00
committed by GitHub
parent de5006a4d8
commit 6e6651c878
101 changed files with 335 additions and 249 deletions

View File

@@ -327,7 +327,6 @@ func (cq *CarQuery) prepareQuery(ctx context.Context) error {
}
cq.sql = prev
}
// Privacy and query checks go here.
return nil
}

View File

@@ -8,6 +8,7 @@ package ent
import (
"context"
"errors"
"fmt"
"strings"
@@ -15,7 +16,6 @@ import (
"github.com/facebookincubator/ent/dialect"
"github.com/facebookincubator/ent/dialect/sql"
"github.com/facebookincubator/ent/dialect/sql/sqlgraph"
"golang.org/x/xerrors"
)
// ent aliases to avoid import conflict in user's code.
@@ -24,6 +24,7 @@ type (
Hook = ent.Hook
Value = ent.Value
Query = ent.Query
Policy = ent.Policy
Mutator = ent.Mutator
Mutation = ent.Mutation
MutateFunc = ent.MutateFunc
@@ -116,7 +117,7 @@ func IsNotFound(err error) bool {
return false
}
var e *NotFoundError
return xerrors.As(err, &e)
return errors.As(err, &e)
}
// MaskNotFound masks nor found error.
@@ -143,7 +144,7 @@ func IsNotSingular(err error) bool {
return false
}
var e *NotSingularError
return xerrors.As(err, &e)
return errors.As(err, &e)
}
// NotLoadedError returns when trying to get a node that was not loaded by the query.
@@ -162,7 +163,7 @@ func IsNotLoaded(err error) bool {
return false
}
var e *NotLoadedError
return xerrors.As(err, &e)
return errors.As(err, &e)
}
// ConstraintError returns when trying to create/update one or more entities and
@@ -189,7 +190,7 @@ func IsConstraintError(err error) bool {
return false
}
var e *ConstraintError
return xerrors.As(err, &e)
return errors.As(err, &e)
}
func isSQLConstraintError(err error) (*ConstraintError, bool) {

View File

@@ -327,7 +327,6 @@ func (gq *GroupQuery) prepareQuery(ctx context.Context) error {
}
gq.sql = prev
}
// Privacy and query checks go here.
return nil
}

View File

@@ -358,7 +358,6 @@ func (uq *UserQuery) prepareQuery(ctx context.Context) error {
}
uq.sql = prev
}
// Privacy and query checks go here.
return nil
}