chore: developer cleanup (#300)

* new PR tasks

* add homebox to know words

* formatting

* bump deps

* generate db models

* ts errors

* drop id

* fix accessor

* drop unused time field

* change CI

* add expected error

* add type check

* resolve serveral type errors

* hoise in CI
This commit is contained in:
Hayden 2023-02-17 21:41:01 -09:00 committed by GitHub
parent 88f9ff90d4
commit bd321af29f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
142 changed files with 817 additions and 1200 deletions

View file

@ -4,7 +4,33 @@ on:
workflow_call: workflow_call:
jobs: jobs:
Frontend: lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2.2.4
with:
version: 6.0.2
- name: Install dependencies
run: pnpm install --shamefully-hoist
working-directory: frontend
- name: Run Lint
run: pnpm run lint:ci
working-directory: frontend
- name: Run Typecheck
run: pnpm run typecheck
working-directory: frontend
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -34,9 +60,5 @@ jobs:
run: pnpm install run: pnpm install
working-directory: frontend working-directory: frontend
- name: Run linter 👀
run: pnpm lint
working-directory: "frontend"
- name: Run Integration Tests - name: Run Integration Tests
run: task test:ci run: task test:ci

View file

@ -9,7 +9,8 @@
"README.md": "LICENSE, SECURITY.md" "README.md": "LICENSE, SECURITY.md"
}, },
"cSpell.words": [ "cSpell.words": [
"debughandlers" "debughandlers",
"Homebox"
], ],
// use ESLint to format code on save // use ESLint to format code on save
"editor.formatOnSave": false, "editor.formatOnSave": false,

View file

@ -108,6 +108,16 @@ tasks:
cmds: cmds:
- cd frontend && pnpm dev - cd frontend && pnpm dev
ui:fix:
desc: Runs prettier and eslint on the frontend
cmds:
- cd frontend && pnpm run lint:fix
ui:check:
desc: Runs type checking
cmds:
- cd frontend && pnpm run typecheck
test:ci: test:ci:
desc: Runs end-to-end test on a live server (only for use in CI) desc: Runs end-to-end test on a live server (only for use in CI)
cmds: cmds:
@ -116,3 +126,12 @@ tasks:
- sleep 5 - sleep 5
- cd frontend && pnpm run test:ci - cd frontend && pnpm run test:ci
silent: true silent: true
pr:
desc: Runs all tasks required for a PR
cmds:
- task: generate
- task: go:all
- task: ui:check
- task: ui:fix
- task: test:ci

View file

@ -50,7 +50,6 @@ func (ctrl *V1Controller) HandleAssetGet() server.HandlerFunc {
} }
} }
items, err := ctrl.repo.Items.QueryByAssetID(r.Context(), ctx.GID, repo.AssetID(assetId), int(page), int(pageSize)) items, err := ctrl.repo.Items.QueryByAssetID(r.Context(), ctx.GID, repo.AssetID(assetId), int(page), int(pageSize))
if err != nil { if err != nil {
log.Err(err).Msg("failed to get item") log.Err(err).Msg("failed to get item")

View file

@ -50,7 +50,6 @@ func (ctrl *V1Controller) HandleAuthLogin() server.HandlerFunc {
loginForm.Password = r.PostFormValue("password") loginForm.Password = r.PostFormValue("password")
case server.ContentJSON: case server.ContentJSON:
err := server.Decode(r, loginForm) err := server.Decode(r, loginForm)
if err != nil { if err != nil {
log.Err(err).Msg("failed to decode login form") log.Err(err).Msg("failed to decode login form")
} }
@ -72,7 +71,6 @@ func (ctrl *V1Controller) HandleAuthLogin() server.HandlerFunc {
} }
newToken, err := ctrl.svc.User.Login(r.Context(), strings.ToLower(loginForm.Username), loginForm.Password) newToken, err := ctrl.svc.User.Login(r.Context(), strings.ToLower(loginForm.Username), loginForm.Password)
if err != nil { if err != nil {
return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError) return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError)
} }

View file

@ -26,7 +26,6 @@ import (
// @Router /v1/items [GET] // @Router /v1/items [GET]
// @Security Bearer // @Security Bearer
func (ctrl *V1Controller) HandleItemsGetAll() server.HandlerFunc { func (ctrl *V1Controller) HandleItemsGetAll() server.HandlerFunc {
extractQuery := func(r *http.Request) repo.ItemQuery { extractQuery := func(r *http.Request) repo.ItemQuery {
params := r.URL.Query() params := r.URL.Query()
@ -244,7 +243,6 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldValues() server.HandlerFunc {
// @Security Bearer // @Security Bearer
func (ctrl *V1Controller) HandleItemsImport() server.HandlerFunc { func (ctrl *V1Controller) HandleItemsImport() server.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error { return func(w http.ResponseWriter, r *http.Request) error {
err := r.ParseMultipartForm(ctrl.maxUploadSize << 20) err := r.ParseMultipartForm(ctrl.maxUploadSize << 20)
if err != nil { if err != nil {
log.Err(err).Msg("failed to parse multipart form") log.Err(err).Msg("failed to parse multipart form")

View file

@ -82,7 +82,6 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() server.HandlerFunc {
attachment.Type(attachmentType), attachment.Type(attachmentType),
file, file,
) )
if err != nil { if err != nil {
log.Err(err).Msg("failed to add attachment") log.Err(err).Msg("failed to add attachment")
return validate.NewRequestError(err, http.StatusInternalServerError) return validate.NewRequestError(err, http.StatusInternalServerError)

View file

@ -34,7 +34,6 @@ func (ctrl *V1Controller) HandleLocationTreeQuery() server.HandlerFunc {
WithItems: withItems, WithItems: withItems,
}, },
) )
if err != nil { if err != nil {
log.Err(err).Msg("failed to get locations tree") log.Err(err).Msg("failed to get locations tree")
return validate.NewRequestError(err, http.StatusInternalServerError) return validate.NewRequestError(err, http.StatusInternalServerError)

View file

@ -80,7 +80,6 @@ func (ctrl *V1Controller) HandleUserSelfUpdate() server.HandlerFunc {
actor := services.UseUserCtx(r.Context()) actor := services.UseUserCtx(r.Context())
newData, err := ctrl.svc.User.UpdateSelf(r.Context(), actor.ID, updateData) newData, err := ctrl.svc.User.UpdateSelf(r.Context(), actor.ID, updateData)
if err != nil { if err != nil {
return validate.NewRequestError(err, http.StatusInternalServerError) return validate.NewRequestError(err, http.StatusInternalServerError)
} }

View file

@ -57,7 +57,7 @@ func run(cfg *config.Config) error {
// ========================================================================= // =========================================================================
// Initialize Database & Repos // Initialize Database & Repos
err := os.MkdirAll(cfg.Storage.Data, 0755) err := os.MkdirAll(cfg.Storage.Data, 0o755)
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("failed to create data directory") log.Fatal().Err(err).Msg("failed to create data directory")
} }

View file

@ -15,9 +15,7 @@ type tokenHasKey struct {
key string key string
} }
var ( var hashedToken = tokenHasKey{key: "hashedToken"}
hashedToken = tokenHasKey{key: "hashedToken"}
)
type RoleMode int type RoleMode int

View file

@ -1722,9 +1722,6 @@ const docTemplate = `{
"textValue": { "textValue": {
"type": "string" "type": "string"
}, },
"timeValue": {
"type": "string"
},
"type": { "type": {
"type": "string" "type": "string"
} }

View file

@ -1714,9 +1714,6 @@
"textValue": { "textValue": {
"type": "string" "type": "string"
}, },
"timeValue": {
"type": "string"
},
"type": { "type": {
"type": "string" "type": "string"
} }

View file

@ -93,8 +93,6 @@ definitions:
type: integer type: integer
textValue: textValue:
type: string type: string
timeValue:
type: string
type: type:
type: string type: string
type: object type: object

View file

@ -1,7 +1,5 @@
ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb h1:mbsFtavDqGdYwdDpP50LGOOZ2hgyGoJcZeOpbgKMyu4= ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb h1:mbsFtavDqGdYwdDpP50LGOOZ2hgyGoJcZeOpbgKMyu4=
ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU= ariga.io/atlas v0.9.1-0.20230119145809-92243f7c55cb/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU=
entgo.io/ent v0.11.7 h1:V+wKFh0jhAbY/FoU+PPbdMOf2Ma5vh07R/IdF+N/nFg=
entgo.io/ent v0.11.7/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18=
entgo.io/ent v0.11.8 h1:M/M0QL1CYCUSdqGRXUrXhFYSDRJPsOOrr+RLEej/gyQ= entgo.io/ent v0.11.8 h1:M/M0QL1CYCUSdqGRXUrXhFYSDRJPsOOrr+RLEej/gyQ=
entgo.io/ent v0.11.8/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18= entgo.io/ent v0.11.8/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
@ -11,8 +9,6 @@ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7l
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/ardanlabs/conf/v3 v3.1.3 h1:16+Nzfc4PBd/ERtYERUFL/75eVKNyW15Y+vn3W1XZzQ=
github.com/ardanlabs/conf/v3 v3.1.3/go.mod h1:bIacyuGeZjkTdtszdbvOcuq49VhHpV3+IPZ2ewOAK4I=
github.com/ardanlabs/conf/v3 v3.1.4 h1:c0jJYbqHJcrR/uYImbGC1q7quH3DYxH49zGCT7WLJH4= github.com/ardanlabs/conf/v3 v3.1.4 h1:c0jJYbqHJcrR/uYImbGC1q7quH3DYxH49zGCT7WLJH4=
github.com/ardanlabs/conf/v3 v3.1.4/go.mod h1:bIacyuGeZjkTdtszdbvOcuq49VhHpV3+IPZ2ewOAK4I= github.com/ardanlabs/conf/v3 v3.1.4/go.mod h1:bIacyuGeZjkTdtszdbvOcuq49VhHpV3+IPZ2ewOAK4I=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=

View file

@ -58,5 +58,4 @@ func TestItemService_AddAttachment(t *testing.T) {
bts, err := os.ReadFile(storedPath) bts, err := os.ReadFile(storedPath)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, contents, string(bts)) assert.Equal(t, contents, string(bts))
} }

View file

@ -139,7 +139,6 @@ func (svc *UserService) UpdateSelf(ctx context.Context, ID uuid.UUID, data repo.
// User Authentication // User Authentication
func (svc *UserService) createSessionToken(ctx context.Context, userId uuid.UUID) (UserAuthTokenDetail, error) { func (svc *UserService) createSessionToken(ctx context.Context, userId uuid.UUID) (UserAuthTokenDetail, error) {
attachmentToken := hasher.GenerateToken() attachmentToken := hasher.GenerateToken()
attachmentData := repo.UserAuthTokenCreate{ attachmentData := repo.UserAuthTokenCreate{
UserID: userId, UserID: userId,
@ -173,7 +172,6 @@ func (svc *UserService) createSessionToken(ctx context.Context, userId uuid.UUID
func (svc *UserService) Login(ctx context.Context, username, password string) (UserAuthTokenDetail, error) { func (svc *UserService) Login(ctx context.Context, username, password string) (UserAuthTokenDetail, error) {
usr, err := svc.repos.Users.GetOneEmail(ctx, username) usr, err := svc.repos.Users.GetOneEmail(ctx, username)
if err != nil { if err != nil {
// SECURITY: Perform hash to ensure response times are the same // SECURITY: Perform hash to ensure response times are the same
hasher.CheckPasswordHash("not-a-real-password", "not-a-real-password") hasher.CheckPasswordHash("not-a-real-password", "not-a-real-password")
@ -197,7 +195,6 @@ func (svc *UserService) RenewToken(ctx context.Context, token string) (UserAuthT
hash := hasher.HashToken(token) hash := hasher.HashToken(token)
dbToken, err := svc.repos.AuthTokens.GetUserFromToken(ctx, hash) dbToken, err := svc.repos.AuthTokens.GetUserFromToken(ctx, hash)
if err != nil { if err != nil {
return UserAuthTokenDetail{}, ErrorInvalidToken return UserAuthTokenDetail{}, ErrorInvalidToken
} }

View file

@ -189,9 +189,3 @@ func (a *Attachment) String() string {
// Attachments is a parsable slice of Attachment. // Attachments is a parsable slice of Attachment.
type Attachments []*Attachment type Attachments []*Attachment
func (a Attachments) config(cfg config) {
for _i := range a {
a[_i].config = cfg
}
}

View file

@ -205,13 +205,7 @@ func (ac *AttachmentCreate) sqlSave(ctx context.Context) (*Attachment, error) {
func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) { func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
var ( var (
_node = &Attachment{config: ac.config} _node = &Attachment{config: ac.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
Table: attachment.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
}
) )
if id, ok := ac.mutation.ID(); ok { if id, ok := ac.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (ad *AttachmentDelete) ExecX(ctx context.Context) int {
} }
func (ad *AttachmentDelete) sqlExec(ctx context.Context) (int, error) { func (ad *AttachmentDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
if ps := ad.mutation.predicates; len(ps) > 0 { if ps := ad.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -227,10 +227,12 @@ func (aq *AttachmentQuery) AllX(ctx context.Context) []*Attachment {
} }
// IDs executes the query and returns a list of Attachment IDs. // IDs executes the query and returns a list of Attachment IDs.
func (aq *AttachmentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (aq *AttachmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if aq.ctx.Unique == nil && aq.path != nil {
aq.Unique(true)
}
ctx = setContextOp(ctx, aq.ctx, "IDs") ctx = setContextOp(ctx, aq.ctx, "IDs")
if err := aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil { if err = aq.Select(attachment.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -525,20 +527,12 @@ func (aq *AttachmentQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec { func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = aq.sql
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
From: aq.sql,
Unique: true,
}
if unique := aq.ctx.Unique; unique != nil { if unique := aq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if aq.path != nil {
_spec.Unique = true
} }
if fields := aq.ctx.Fields; len(fields) > 0 { if fields := aq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -146,16 +146,7 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := au.check(); err != nil { if err := au.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
if ps := au.mutation.predicates; len(ps) > 0 { if ps := au.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -318,6 +309,12 @@ func (auo *AttachmentUpdateOne) ClearDocument() *AttachmentUpdateOne {
return auo return auo
} }
// Where appends a list predicates to the AttachmentUpdate builder.
func (auo *AttachmentUpdateOne) Where(ps ...predicate.Attachment) *AttachmentUpdateOne {
auo.mutation.Where(ps...)
return auo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (auo *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne { func (auo *AttachmentUpdateOne) Select(field string, fields ...string) *AttachmentUpdateOne {
@ -381,16 +378,7 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
if err := auo.check(); err != nil { if err := auo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
id, ok := auo.mutation.ID() id, ok := auo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attachment.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Attachment.id" for update`)}

View file

@ -133,9 +133,3 @@ func (ar *AuthRoles) String() string {
// AuthRolesSlice is a parsable slice of AuthRoles. // AuthRolesSlice is a parsable slice of AuthRoles.
type AuthRolesSlice []*AuthRoles type AuthRolesSlice []*AuthRoles
func (ar AuthRolesSlice) config(cfg config) {
for _i := range ar {
ar[_i].config = cfg
}
}

View file

@ -129,13 +129,7 @@ func (arc *AuthRolesCreate) sqlSave(ctx context.Context) (*AuthRoles, error) {
func (arc *AuthRolesCreate) createSpec() (*AuthRoles, *sqlgraph.CreateSpec) { func (arc *AuthRolesCreate) createSpec() (*AuthRoles, *sqlgraph.CreateSpec) {
var ( var (
_node = &AuthRoles{config: arc.config} _node = &AuthRoles{config: arc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
Table: authroles.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
}
) )
if value, ok := arc.mutation.Role(); ok { if value, ok := arc.mutation.Role(); ok {
_spec.SetField(authroles.FieldRole, field.TypeEnum, value) _spec.SetField(authroles.FieldRole, field.TypeEnum, value)

View file

@ -40,15 +40,7 @@ func (ard *AuthRolesDelete) ExecX(ctx context.Context) int {
} }
func (ard *AuthRolesDelete) sqlExec(ctx context.Context) (int, error) { func (ard *AuthRolesDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
if ps := ard.mutation.predicates; len(ps) > 0 { if ps := ard.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -203,10 +203,12 @@ func (arq *AuthRolesQuery) AllX(ctx context.Context) []*AuthRoles {
} }
// IDs executes the query and returns a list of AuthRoles IDs. // IDs executes the query and returns a list of AuthRoles IDs.
func (arq *AuthRolesQuery) IDs(ctx context.Context) ([]int, error) { func (arq *AuthRolesQuery) IDs(ctx context.Context) (ids []int, err error) {
var ids []int if arq.ctx.Unique == nil && arq.path != nil {
arq.Unique(true)
}
ctx = setContextOp(ctx, arq.ctx, "IDs") ctx = setContextOp(ctx, arq.ctx, "IDs")
if err := arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil { if err = arq.Select(authroles.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -450,20 +452,12 @@ func (arq *AuthRolesQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec { func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
Node: &sqlgraph.NodeSpec{ _spec.From = arq.sql
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
From: arq.sql,
Unique: true,
}
if unique := arq.ctx.Unique; unique != nil { if unique := arq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if arq.path != nil {
_spec.Unique = true
} }
if fields := arq.ctx.Fields; len(fields) > 0 { if fields := arq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -114,16 +114,7 @@ func (aru *AuthRolesUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := aru.check(); err != nil { if err := aru.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
if ps := aru.mutation.predicates; len(ps) > 0 { if ps := aru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -233,6 +224,12 @@ func (aruo *AuthRolesUpdateOne) ClearToken() *AuthRolesUpdateOne {
return aruo return aruo
} }
// Where appends a list predicates to the AuthRolesUpdate builder.
func (aruo *AuthRolesUpdateOne) Where(ps ...predicate.AuthRoles) *AuthRolesUpdateOne {
aruo.mutation.Where(ps...)
return aruo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (aruo *AuthRolesUpdateOne) Select(field string, fields ...string) *AuthRolesUpdateOne { func (aruo *AuthRolesUpdateOne) Select(field string, fields ...string) *AuthRolesUpdateOne {
@ -281,16 +278,7 @@ func (aruo *AuthRolesUpdateOne) sqlSave(ctx context.Context) (_node *AuthRoles,
if err := aruo.check(); err != nil { if err := aruo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
id, ok := aruo.mutation.ID() id, ok := aruo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthRoles.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthRoles.id" for update`)}

View file

@ -190,9 +190,3 @@ func (at *AuthTokens) String() string {
// AuthTokensSlice is a parsable slice of AuthTokens. // AuthTokensSlice is a parsable slice of AuthTokens.
type AuthTokensSlice []*AuthTokens type AuthTokensSlice []*AuthTokens
func (at AuthTokensSlice) config(cfg config) {
for _i := range at {
at[_i].config = cfg
}
}

View file

@ -219,13 +219,7 @@ func (atc *AuthTokensCreate) sqlSave(ctx context.Context) (*AuthTokens, error) {
func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) { func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
var ( var (
_node = &AuthTokens{config: atc.config} _node = &AuthTokens{config: atc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
Table: authtokens.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
}
) )
if id, ok := atc.mutation.ID(); ok { if id, ok := atc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (atd *AuthTokensDelete) ExecX(ctx context.Context) int {
} }
func (atd *AuthTokensDelete) sqlExec(ctx context.Context) (int, error) { func (atd *AuthTokensDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
if ps := atd.mutation.predicates; len(ps) > 0 { if ps := atd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -228,10 +228,12 @@ func (atq *AuthTokensQuery) AllX(ctx context.Context) []*AuthTokens {
} }
// IDs executes the query and returns a list of AuthTokens IDs. // IDs executes the query and returns a list of AuthTokens IDs.
func (atq *AuthTokensQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (atq *AuthTokensQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if atq.ctx.Unique == nil && atq.path != nil {
atq.Unique(true)
}
ctx = setContextOp(ctx, atq.ctx, "IDs") ctx = setContextOp(ctx, atq.ctx, "IDs")
if err := atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil { if err = atq.Select(authtokens.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -522,20 +524,12 @@ func (atq *AuthTokensQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec { func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = atq.sql
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
From: atq.sql,
Unique: true,
}
if unique := atq.ctx.Unique; unique != nil { if unique := atq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if atq.path != nil {
_spec.Unique = true
} }
if fields := atq.ctx.Fields; len(fields) > 0 { if fields := atq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -149,16 +149,7 @@ func (atu *AuthTokensUpdate) defaults() {
} }
func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) { func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
if ps := atu.mutation.predicates; len(ps) > 0 { if ps := atu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -346,6 +337,12 @@ func (atuo *AuthTokensUpdateOne) ClearRoles() *AuthTokensUpdateOne {
return atuo return atuo
} }
// Where appends a list predicates to the AuthTokensUpdate builder.
func (atuo *AuthTokensUpdateOne) Where(ps ...predicate.AuthTokens) *AuthTokensUpdateOne {
atuo.mutation.Where(ps...)
return atuo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (atuo *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTokensUpdateOne { func (atuo *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTokensUpdateOne {
@ -390,16 +387,7 @@ func (atuo *AuthTokensUpdateOne) defaults() {
} }
func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens, err error) { func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens, err error) {
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
id, ok := atuo.mutation.ID() id, ok := atuo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthTokens.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthTokens.id" for update`)}

View file

@ -266,7 +266,7 @@ func (c *AttachmentClient) Use(hooks ...Hook) {
c.hooks.Attachment = append(c.hooks.Attachment, hooks...) c.hooks.Attachment = append(c.hooks.Attachment, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `attachment.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `attachment.Intercept(f(g(h())))`.
func (c *AttachmentClient) Intercept(interceptors ...Interceptor) { func (c *AttachmentClient) Intercept(interceptors ...Interceptor) {
c.inters.Attachment = append(c.inters.Attachment, interceptors...) c.inters.Attachment = append(c.inters.Attachment, interceptors...)
@ -416,7 +416,7 @@ func (c *AuthRolesClient) Use(hooks ...Hook) {
c.hooks.AuthRoles = append(c.hooks.AuthRoles, hooks...) c.hooks.AuthRoles = append(c.hooks.AuthRoles, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authroles.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `authroles.Intercept(f(g(h())))`.
func (c *AuthRolesClient) Intercept(interceptors ...Interceptor) { func (c *AuthRolesClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthRoles = append(c.inters.AuthRoles, interceptors...) c.inters.AuthRoles = append(c.inters.AuthRoles, interceptors...)
@ -550,7 +550,7 @@ func (c *AuthTokensClient) Use(hooks ...Hook) {
c.hooks.AuthTokens = append(c.hooks.AuthTokens, hooks...) c.hooks.AuthTokens = append(c.hooks.AuthTokens, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authtokens.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `authtokens.Intercept(f(g(h())))`.
func (c *AuthTokensClient) Intercept(interceptors ...Interceptor) { func (c *AuthTokensClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthTokens = append(c.inters.AuthTokens, interceptors...) c.inters.AuthTokens = append(c.inters.AuthTokens, interceptors...)
@ -700,7 +700,7 @@ func (c *DocumentClient) Use(hooks ...Hook) {
c.hooks.Document = append(c.hooks.Document, hooks...) c.hooks.Document = append(c.hooks.Document, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `document.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `document.Intercept(f(g(h())))`.
func (c *DocumentClient) Intercept(interceptors ...Interceptor) { func (c *DocumentClient) Intercept(interceptors ...Interceptor) {
c.inters.Document = append(c.inters.Document, interceptors...) c.inters.Document = append(c.inters.Document, interceptors...)
@ -850,7 +850,7 @@ func (c *GroupClient) Use(hooks ...Hook) {
c.hooks.Group = append(c.hooks.Group, hooks...) c.hooks.Group = append(c.hooks.Group, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `group.Intercept(f(g(h())))`.
func (c *GroupClient) Intercept(interceptors ...Interceptor) { func (c *GroupClient) Intercept(interceptors ...Interceptor) {
c.inters.Group = append(c.inters.Group, interceptors...) c.inters.Group = append(c.inters.Group, interceptors...)
@ -1064,7 +1064,7 @@ func (c *GroupInvitationTokenClient) Use(hooks ...Hook) {
c.hooks.GroupInvitationToken = append(c.hooks.GroupInvitationToken, hooks...) c.hooks.GroupInvitationToken = append(c.hooks.GroupInvitationToken, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `groupinvitationtoken.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `groupinvitationtoken.Intercept(f(g(h())))`.
func (c *GroupInvitationTokenClient) Intercept(interceptors ...Interceptor) { func (c *GroupInvitationTokenClient) Intercept(interceptors ...Interceptor) {
c.inters.GroupInvitationToken = append(c.inters.GroupInvitationToken, interceptors...) c.inters.GroupInvitationToken = append(c.inters.GroupInvitationToken, interceptors...)
@ -1198,7 +1198,7 @@ func (c *ItemClient) Use(hooks ...Hook) {
c.hooks.Item = append(c.hooks.Item, hooks...) c.hooks.Item = append(c.hooks.Item, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `item.Intercept(f(g(h())))`.
func (c *ItemClient) Intercept(interceptors ...Interceptor) { func (c *ItemClient) Intercept(interceptors ...Interceptor) {
c.inters.Item = append(c.inters.Item, interceptors...) c.inters.Item = append(c.inters.Item, interceptors...)
@ -1444,7 +1444,7 @@ func (c *ItemFieldClient) Use(hooks ...Hook) {
c.hooks.ItemField = append(c.hooks.ItemField, hooks...) c.hooks.ItemField = append(c.hooks.ItemField, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `itemfield.Intercept(f(g(h())))`.
func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) { func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) {
c.inters.ItemField = append(c.inters.ItemField, interceptors...) c.inters.ItemField = append(c.inters.ItemField, interceptors...)
@ -1578,7 +1578,7 @@ func (c *LabelClient) Use(hooks ...Hook) {
c.hooks.Label = append(c.hooks.Label, hooks...) c.hooks.Label = append(c.hooks.Label, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
func (c *LabelClient) Intercept(interceptors ...Interceptor) { func (c *LabelClient) Intercept(interceptors ...Interceptor) {
c.inters.Label = append(c.inters.Label, interceptors...) c.inters.Label = append(c.inters.Label, interceptors...)
@ -1728,7 +1728,7 @@ func (c *LocationClient) Use(hooks ...Hook) {
c.hooks.Location = append(c.hooks.Location, hooks...) c.hooks.Location = append(c.hooks.Location, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `location.Intercept(f(g(h())))`.
func (c *LocationClient) Intercept(interceptors ...Interceptor) { func (c *LocationClient) Intercept(interceptors ...Interceptor) {
c.inters.Location = append(c.inters.Location, interceptors...) c.inters.Location = append(c.inters.Location, interceptors...)
@ -1910,7 +1910,7 @@ func (c *MaintenanceEntryClient) Use(hooks ...Hook) {
c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...) c.hooks.MaintenanceEntry = append(c.hooks.MaintenanceEntry, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `maintenanceentry.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `maintenanceentry.Intercept(f(g(h())))`.
func (c *MaintenanceEntryClient) Intercept(interceptors ...Interceptor) { func (c *MaintenanceEntryClient) Intercept(interceptors ...Interceptor) {
c.inters.MaintenanceEntry = append(c.inters.MaintenanceEntry, interceptors...) c.inters.MaintenanceEntry = append(c.inters.MaintenanceEntry, interceptors...)
@ -2044,7 +2044,7 @@ func (c *UserClient) Use(hooks ...Hook) {
c.hooks.User = append(c.hooks.User, hooks...) c.hooks.User = append(c.hooks.User, hooks...)
} }
// Use adds a list of query interceptors to the interceptors stack. // Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. // A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`.
func (c *UserClient) Intercept(interceptors ...Interceptor) { func (c *UserClient) Intercept(interceptors ...Interceptor) {
c.inters.User = append(c.inters.User, interceptors...) c.inters.User = append(c.inters.User, interceptors...)

View file

@ -185,9 +185,3 @@ func (d *Document) String() string {
// Documents is a parsable slice of Document. // Documents is a parsable slice of Document.
type Documents []*Document type Documents []*Document
func (d Documents) config(cfg config) {
for _i := range d {
d[_i].config = cfg
}
}

View file

@ -208,13 +208,7 @@ func (dc *DocumentCreate) sqlSave(ctx context.Context) (*Document, error) {
func (dc *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) { func (dc *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) {
var ( var (
_node = &Document{config: dc.config} _node = &Document{config: dc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(document.Table, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
Table: document.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
}
) )
if id, ok := dc.mutation.ID(); ok { if id, ok := dc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (dd *DocumentDelete) ExecX(ctx context.Context) int {
} }
func (dd *DocumentDelete) sqlExec(ctx context.Context) (int, error) { func (dd *DocumentDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(document.Table, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: document.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
if ps := dd.mutation.predicates; len(ps) > 0 { if ps := dd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -228,10 +228,12 @@ func (dq *DocumentQuery) AllX(ctx context.Context) []*Document {
} }
// IDs executes the query and returns a list of Document IDs. // IDs executes the query and returns a list of Document IDs.
func (dq *DocumentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (dq *DocumentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if dq.ctx.Unique == nil && dq.path != nil {
dq.Unique(true)
}
ctx = setContextOp(ctx, dq.ctx, "IDs") ctx = setContextOp(ctx, dq.ctx, "IDs")
if err := dq.Select(document.FieldID).Scan(ctx, &ids); err != nil { if err = dq.Select(document.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -526,20 +528,12 @@ func (dq *DocumentQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (dq *DocumentQuery) querySpec() *sqlgraph.QuerySpec { func (dq *DocumentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = dq.sql
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
From: dq.sql,
Unique: true,
}
if unique := dq.ctx.Unique; unique != nil { if unique := dq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if dq.path != nil {
_spec.Unique = true
} }
if fields := dq.ctx.Fields; len(fields) > 0 { if fields := dq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -165,16 +165,7 @@ func (du *DocumentUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := du.check(); err != nil { if err := du.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
if ps := du.mutation.predicates; len(ps) > 0 { if ps := du.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -376,6 +367,12 @@ func (duo *DocumentUpdateOne) RemoveAttachments(a ...*Attachment) *DocumentUpdat
return duo.RemoveAttachmentIDs(ids...) return duo.RemoveAttachmentIDs(ids...)
} }
// Where appends a list predicates to the DocumentUpdate builder.
func (duo *DocumentUpdateOne) Where(ps ...predicate.Document) *DocumentUpdateOne {
duo.mutation.Where(ps...)
return duo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (duo *DocumentUpdateOne) Select(field string, fields ...string) *DocumentUpdateOne { func (duo *DocumentUpdateOne) Select(field string, fields ...string) *DocumentUpdateOne {
@ -441,16 +438,7 @@ func (duo *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err
if err := duo.check(); err != nil { if err := duo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
id, ok := duo.mutation.ID() id, ok := duo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Document.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Document.id" for update`)}

View file

@ -234,9 +234,3 @@ func (gr *Group) String() string {
// Groups is a parsable slice of Group. // Groups is a parsable slice of Group.
type Groups []*Group type Groups []*Group
func (gr Groups) config(cfg config) {
for _i := range gr {
gr[_i].config = cfg
}
}

View file

@ -285,13 +285,7 @@ func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) {
func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
var ( var (
_node = &Group{config: gc.config} _node = &Group{config: gc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
Table: group.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
}
) )
if id, ok := gc.mutation.ID(); ok { if id, ok := gc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (gd *GroupDelete) ExecX(ctx context.Context) int {
} }
func (gd *GroupDelete) sqlExec(ctx context.Context) (int, error) { func (gd *GroupDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: group.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
if ps := gd.mutation.predicates; len(ps) > 0 { if ps := gd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -323,10 +323,12 @@ func (gq *GroupQuery) AllX(ctx context.Context) []*Group {
} }
// IDs executes the query and returns a list of Group IDs. // IDs executes the query and returns a list of Group IDs.
func (gq *GroupQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (gq *GroupQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if gq.ctx.Unique == nil && gq.path != nil {
gq.Unique(true)
}
ctx = setContextOp(ctx, gq.ctx, "IDs") ctx = setContextOp(ctx, gq.ctx, "IDs")
if err := gq.Select(group.FieldID).Scan(ctx, &ids); err != nil { if err = gq.Select(group.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -820,20 +822,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec { func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = gq.sql
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
From: gq.sql,
Unique: true,
}
if unique := gq.ctx.Unique; unique != nil { if unique := gq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if gq.path != nil {
_spec.Unique = true
} }
if fields := gq.ctx.Fields; len(fields) > 0 { if fields := gq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -337,16 +337,7 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := gu.check(); err != nil { if err := gu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
if ps := gu.mutation.predicates; len(ps) > 0 { if ps := gu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -954,6 +945,12 @@ func (guo *GroupUpdateOne) RemoveInvitationTokens(g ...*GroupInvitationToken) *G
return guo.RemoveInvitationTokenIDs(ids...) return guo.RemoveInvitationTokenIDs(ids...)
} }
// Where appends a list predicates to the GroupUpdate builder.
func (guo *GroupUpdateOne) Where(ps ...predicate.Group) *GroupUpdateOne {
guo.mutation.Where(ps...)
return guo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOne { func (guo *GroupUpdateOne) Select(field string, fields ...string) *GroupUpdateOne {
@ -1016,16 +1013,7 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
if err := guo.check(); err != nil { if err := guo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
id, ok := guo.mutation.ID() id, ok := guo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Group.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Group.id" for update`)}

View file

@ -182,9 +182,3 @@ func (git *GroupInvitationToken) String() string {
// GroupInvitationTokens is a parsable slice of GroupInvitationToken. // GroupInvitationTokens is a parsable slice of GroupInvitationToken.
type GroupInvitationTokens []*GroupInvitationToken type GroupInvitationTokens []*GroupInvitationToken
func (git GroupInvitationTokens) config(cfg config) {
for _i := range git {
git[_i].config = cfg
}
}

View file

@ -220,13 +220,7 @@ func (gitc *GroupInvitationTokenCreate) sqlSave(ctx context.Context) (*GroupInvi
func (gitc *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sqlgraph.CreateSpec) { func (gitc *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sqlgraph.CreateSpec) {
var ( var (
_node = &GroupInvitationToken{config: gitc.config} _node = &GroupInvitationToken{config: gitc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
Table: groupinvitationtoken.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
}
) )
if id, ok := gitc.mutation.ID(); ok { if id, ok := gitc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (gitd *GroupInvitationTokenDelete) ExecX(ctx context.Context) int {
} }
func (gitd *GroupInvitationTokenDelete) sqlExec(ctx context.Context) (int, error) { func (gitd *GroupInvitationTokenDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
if ps := gitd.mutation.predicates; len(ps) > 0 { if ps := gitd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -203,10 +203,12 @@ func (gitq *GroupInvitationTokenQuery) AllX(ctx context.Context) []*GroupInvitat
} }
// IDs executes the query and returns a list of GroupInvitationToken IDs. // IDs executes the query and returns a list of GroupInvitationToken IDs.
func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if gitq.ctx.Unique == nil && gitq.path != nil {
gitq.Unique(true)
}
ctx = setContextOp(ctx, gitq.ctx, "IDs") ctx = setContextOp(ctx, gitq.ctx, "IDs")
if err := gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil { if err = gitq.Select(groupinvitationtoken.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -450,20 +452,12 @@ func (gitq *GroupInvitationTokenQuery) sqlCount(ctx context.Context) (int, error
} }
func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec { func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = gitq.sql
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
From: gitq.sql,
Unique: true,
}
if unique := gitq.ctx.Unique; unique != nil { if unique := gitq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if gitq.path != nil {
_spec.Unique = true
} }
if fields := gitq.ctx.Fields; len(fields) > 0 { if fields := gitq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -144,16 +144,7 @@ func (gitu *GroupInvitationTokenUpdate) defaults() {
} }
func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err error) { func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
if ps := gitu.mutation.predicates; len(ps) > 0 { if ps := gitu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -308,6 +299,12 @@ func (gituo *GroupInvitationTokenUpdateOne) ClearGroup() *GroupInvitationTokenUp
return gituo return gituo
} }
// Where appends a list predicates to the GroupInvitationTokenUpdate builder.
func (gituo *GroupInvitationTokenUpdateOne) Where(ps ...predicate.GroupInvitationToken) *GroupInvitationTokenUpdateOne {
gituo.mutation.Where(ps...)
return gituo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (gituo *GroupInvitationTokenUpdateOne) Select(field string, fields ...string) *GroupInvitationTokenUpdateOne { func (gituo *GroupInvitationTokenUpdateOne) Select(field string, fields ...string) *GroupInvitationTokenUpdateOne {
@ -352,16 +349,7 @@ func (gituo *GroupInvitationTokenUpdateOne) defaults() {
} }
func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node *GroupInvitationToken, err error) { func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node *GroupInvitationToken, err error) {
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
id, ok := gituo.mutation.ID() id, ok := gituo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GroupInvitationToken.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GroupInvitationToken.id" for update`)}

View file

@ -525,9 +525,3 @@ func (i *Item) String() string {
// Items is a parsable slice of Item. // Items is a parsable slice of Item.
type Items []*Item type Items []*Item
func (i Items) config(cfg config) {
for _i := range i {
i[_i].config = cfg
}
}

View file

@ -665,13 +665,7 @@ func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) {
func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) { func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
var ( var (
_node = &Item{config: ic.config} _node = &Item{config: ic.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
Table: item.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
}
) )
if id, ok := ic.mutation.ID(); ok { if id, ok := ic.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (id *ItemDelete) ExecX(ctx context.Context) int {
} }
func (id *ItemDelete) sqlExec(ctx context.Context) (int, error) { func (id *ItemDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: item.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
if ps := id.mutation.predicates; len(ps) > 0 { if ps := id.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -370,10 +370,12 @@ func (iq *ItemQuery) AllX(ctx context.Context) []*Item {
} }
// IDs executes the query and returns a list of Item IDs. // IDs executes the query and returns a list of Item IDs.
func (iq *ItemQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (iq *ItemQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if iq.ctx.Unique == nil && iq.path != nil {
iq.Unique(true)
}
ctx = setContextOp(ctx, iq.ctx, "IDs") ctx = setContextOp(ctx, iq.ctx, "IDs")
if err := iq.Select(item.FieldID).Scan(ctx, &ids); err != nil { if err = iq.Select(item.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -1000,20 +1002,12 @@ func (iq *ItemQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec { func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = iq.sql
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
From: iq.sql,
Unique: true,
}
if unique := iq.ctx.Unique; unique != nil { if unique := iq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if iq.path != nil {
_spec.Unique = true
} }
if fields := iq.ctx.Fields; len(fields) > 0 { if fields := iq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -753,16 +753,7 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := iu.check(); err != nil { if err := iu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
if ps := iu.mutation.predicates; len(ps) > 0 { if ps := iu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -1909,6 +1900,12 @@ func (iuo *ItemUpdateOne) RemoveAttachments(a ...*Attachment) *ItemUpdateOne {
return iuo.RemoveAttachmentIDs(ids...) return iuo.RemoveAttachmentIDs(ids...)
} }
// Where appends a list predicates to the ItemUpdate builder.
func (iuo *ItemUpdateOne) Where(ps ...predicate.Item) *ItemUpdateOne {
iuo.mutation.Where(ps...)
return iuo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (iuo *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne { func (iuo *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne {
@ -2004,16 +2001,7 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
if err := iuo.check(); err != nil { if err := iuo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
id, ok := iuo.mutation.ID() id, ok := iuo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Item.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Item.id" for update`)}

View file

@ -228,9 +228,3 @@ func (_if *ItemField) String() string {
// ItemFields is a parsable slice of ItemField. // ItemFields is a parsable slice of ItemField.
type ItemFields []*ItemField type ItemFields []*ItemField
func (_if ItemFields) config(cfg config) {
for _i := range _if {
_if[_i].config = cfg
}
}

View file

@ -291,13 +291,7 @@ func (ifc *ItemFieldCreate) sqlSave(ctx context.Context) (*ItemField, error) {
func (ifc *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) { func (ifc *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) {
var ( var (
_node = &ItemField{config: ifc.config} _node = &ItemField{config: ifc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
Table: itemfield.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
}
) )
if id, ok := ifc.mutation.ID(); ok { if id, ok := ifc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (ifd *ItemFieldDelete) ExecX(ctx context.Context) int {
} }
func (ifd *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) { func (ifd *ItemFieldDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
if ps := ifd.mutation.predicates; len(ps) > 0 { if ps := ifd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -203,10 +203,12 @@ func (ifq *ItemFieldQuery) AllX(ctx context.Context) []*ItemField {
} }
// IDs executes the query and returns a list of ItemField IDs. // IDs executes the query and returns a list of ItemField IDs.
func (ifq *ItemFieldQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (ifq *ItemFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if ifq.ctx.Unique == nil && ifq.path != nil {
ifq.Unique(true)
}
ctx = setContextOp(ctx, ifq.ctx, "IDs") ctx = setContextOp(ctx, ifq.ctx, "IDs")
if err := ifq.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil { if err = ifq.Select(itemfield.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -450,20 +452,12 @@ func (ifq *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (ifq *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec { func (ifq *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = ifq.sql
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
From: ifq.sql,
Unique: true,
}
if unique := ifq.ctx.Unique; unique != nil { if unique := ifq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if ifq.path != nil {
_spec.Unique = true
} }
if fields := ifq.ctx.Fields; len(fields) > 0 { if fields := ifq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -238,16 +238,7 @@ func (ifu *ItemFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := ifu.check(); err != nil { if err := ifu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
if ps := ifu.mutation.predicates; len(ps) > 0 { if ps := ifu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -489,6 +480,12 @@ func (ifuo *ItemFieldUpdateOne) ClearItem() *ItemFieldUpdateOne {
return ifuo return ifuo
} }
// Where appends a list predicates to the ItemFieldUpdate builder.
func (ifuo *ItemFieldUpdateOne) Where(ps ...predicate.ItemField) *ItemFieldUpdateOne {
ifuo.mutation.Where(ps...)
return ifuo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (ifuo *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFieldUpdateOne { func (ifuo *ItemFieldUpdateOne) Select(field string, fields ...string) *ItemFieldUpdateOne {
@ -561,16 +558,7 @@ func (ifuo *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField,
if err := ifuo.check(); err != nil { if err := ifuo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
id, ok := ifuo.mutation.ID() id, ok := ifuo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemField.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ItemField.id" for update`)}

View file

@ -196,9 +196,3 @@ func (l *Label) String() string {
// Labels is a parsable slice of Label. // Labels is a parsable slice of Label.
type Labels []*Label type Labels []*Label
func (l Labels) config(cfg config) {
for _i := range l {
l[_i].config = cfg
}
}

View file

@ -232,13 +232,7 @@ func (lc *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) { func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
var ( var (
_node = &Label{config: lc.config} _node = &Label{config: lc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
Table: label.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
}
) )
if id, ok := lc.mutation.ID(); ok { if id, ok := lc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (ld *LabelDelete) ExecX(ctx context.Context) int {
} }
func (ld *LabelDelete) sqlExec(ctx context.Context) (int, error) { func (ld *LabelDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: label.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
if ps := ld.mutation.predicates; len(ps) > 0 { if ps := ld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -228,10 +228,12 @@ func (lq *LabelQuery) AllX(ctx context.Context) []*Label {
} }
// IDs executes the query and returns a list of Label IDs. // IDs executes the query and returns a list of Label IDs.
func (lq *LabelQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (lq *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
ctx = setContextOp(ctx, lq.ctx, "IDs") ctx = setContextOp(ctx, lq.ctx, "IDs")
if err := lq.Select(label.FieldID).Scan(ctx, &ids); err != nil { if err = lq.Select(label.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -556,20 +558,12 @@ func (lq *LabelQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec { func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = lq.sql
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
From: lq.sql,
Unique: true,
}
if unique := lq.ctx.Unique; unique != nil { if unique := lq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if lq.path != nil {
_spec.Unique = true
} }
if fields := lq.ctx.Fields; len(fields) > 0 { if fields := lq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -204,16 +204,7 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := lu.check(); err != nil { if err := lu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
if ps := lu.mutation.predicates; len(ps) > 0 { if ps := lu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -458,6 +449,12 @@ func (luo *LabelUpdateOne) RemoveItems(i ...*Item) *LabelUpdateOne {
return luo.RemoveItemIDs(ids...) return luo.RemoveItemIDs(ids...)
} }
// Where appends a list predicates to the LabelUpdate builder.
func (luo *LabelUpdateOne) Where(ps ...predicate.Label) *LabelUpdateOne {
luo.mutation.Where(ps...)
return luo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (luo *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOne { func (luo *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOne {
@ -528,16 +525,7 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
if err := luo.check(); err != nil { if err := luo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
id, ok := luo.mutation.ID() id, ok := luo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Label.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Label.id" for update`)}

View file

@ -231,9 +231,3 @@ func (l *Location) String() string {
// Locations is a parsable slice of Location. // Locations is a parsable slice of Location.
type Locations []*Location type Locations []*Location
func (l Locations) config(cfg config) {
for _i := range l {
l[_i].config = cfg
}
}

View file

@ -247,13 +247,7 @@ func (lc *LocationCreate) sqlSave(ctx context.Context) (*Location, error) {
func (lc *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) { func (lc *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
var ( var (
_node = &Location{config: lc.config} _node = &Location{config: lc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
Table: location.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
}
) )
if id, ok := lc.mutation.ID(); ok { if id, ok := lc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (ld *LocationDelete) ExecX(ctx context.Context) int {
} }
func (ld *LocationDelete) sqlExec(ctx context.Context) (int, error) { func (ld *LocationDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: location.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
if ps := ld.mutation.predicates; len(ps) > 0 { if ps := ld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -274,10 +274,12 @@ func (lq *LocationQuery) AllX(ctx context.Context) []*Location {
} }
// IDs executes the query and returns a list of Location IDs. // IDs executes the query and returns a list of Location IDs.
func (lq *LocationQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (lq *LocationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
ctx = setContextOp(ctx, lq.ctx, "IDs") ctx = setContextOp(ctx, lq.ctx, "IDs")
if err := lq.Select(location.FieldID).Scan(ctx, &ids); err != nil { if err = lq.Select(location.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -674,20 +676,12 @@ func (lq *LocationQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (lq *LocationQuery) querySpec() *sqlgraph.QuerySpec { func (lq *LocationQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = lq.sql
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
From: lq.sql,
Unique: true,
}
if unique := lq.ctx.Unique; unique != nil { if unique := lq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if lq.path != nil {
_spec.Unique = true
} }
if fields := lq.ctx.Fields; len(fields) > 0 { if fields := lq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -240,16 +240,7 @@ func (lu *LocationUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := lu.check(); err != nil { if err := lu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
if ps := lu.mutation.predicates; len(ps) > 0 { if ps := lu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -618,6 +609,12 @@ func (luo *LocationUpdateOne) RemoveItems(i ...*Item) *LocationUpdateOne {
return luo.RemoveItemIDs(ids...) return luo.RemoveItemIDs(ids...)
} }
// Where appends a list predicates to the LocationUpdate builder.
func (luo *LocationUpdateOne) Where(ps ...predicate.Location) *LocationUpdateOne {
luo.mutation.Where(ps...)
return luo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (luo *LocationUpdateOne) Select(field string, fields ...string) *LocationUpdateOne { func (luo *LocationUpdateOne) Select(field string, fields ...string) *LocationUpdateOne {
@ -683,16 +680,7 @@ func (luo *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err
if err := luo.check(); err != nil { if err := luo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
id, ok := luo.mutation.ID() id, ok := luo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Location.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Location.id" for update`)}

View file

@ -194,9 +194,3 @@ func (me *MaintenanceEntry) String() string {
// MaintenanceEntries is a parsable slice of MaintenanceEntry. // MaintenanceEntries is a parsable slice of MaintenanceEntry.
type MaintenanceEntries []*MaintenanceEntry type MaintenanceEntries []*MaintenanceEntry
func (me MaintenanceEntries) config(cfg config) {
for _i := range me {
me[_i].config = cfg
}
}

View file

@ -242,13 +242,7 @@ func (mec *MaintenanceEntryCreate) sqlSave(ctx context.Context) (*MaintenanceEnt
func (mec *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.CreateSpec) { func (mec *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.CreateSpec) {
var ( var (
_node = &MaintenanceEntry{config: mec.config} _node = &MaintenanceEntry{config: mec.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
Table: maintenanceentry.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
}
) )
if id, ok := mec.mutation.ID(); ok { if id, ok := mec.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (med *MaintenanceEntryDelete) ExecX(ctx context.Context) int {
} }
func (med *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) { func (med *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
if ps := med.mutation.predicates; len(ps) > 0 { if ps := med.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -202,10 +202,12 @@ func (meq *MaintenanceEntryQuery) AllX(ctx context.Context) []*MaintenanceEntry
} }
// IDs executes the query and returns a list of MaintenanceEntry IDs. // IDs executes the query and returns a list of MaintenanceEntry IDs.
func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if meq.ctx.Unique == nil && meq.path != nil {
meq.Unique(true)
}
ctx = setContextOp(ctx, meq.ctx, "IDs") ctx = setContextOp(ctx, meq.ctx, "IDs")
if err := meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil { if err = meq.Select(maintenanceentry.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -439,20 +441,12 @@ func (meq *MaintenanceEntryQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec { func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = meq.sql
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
From: meq.sql,
Unique: true,
}
if unique := meq.ctx.Unique; unique != nil { if unique := meq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if meq.path != nil {
_spec.Unique = true
} }
if fields := meq.ctx.Fields; len(fields) > 0 { if fields := meq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -177,16 +177,7 @@ func (meu *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (n int, err erro
if err := meu.check(); err != nil { if err := meu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
if ps := meu.mutation.predicates; len(ps) > 0 { if ps := meu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -359,6 +350,12 @@ func (meuo *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne {
return meuo return meuo
} }
// Where appends a list predicates to the MaintenanceEntryUpdate builder.
func (meuo *MaintenanceEntryUpdateOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryUpdateOne {
meuo.mutation.Where(ps...)
return meuo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (meuo *MaintenanceEntryUpdateOne) Select(field string, fields ...string) *MaintenanceEntryUpdateOne { func (meuo *MaintenanceEntryUpdateOne) Select(field string, fields ...string) *MaintenanceEntryUpdateOne {
@ -424,16 +421,7 @@ func (meuo *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Main
if err := meuo.check(); err != nil { if err := meuo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
id, ok := meuo.mutation.ID() id, ok := meuo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MaintenanceEntry.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MaintenanceEntry.id" for update`)}

View file

@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go // The schema-stitching logic is generated in github.com/hay-kot/homebox/backend/internal/data/ent/runtime.go
const ( const (
Version = "v0.11.7" // Version of ent codegen. Version = "v0.11.8" // Version of ent codegen.
Sum = "h1:V+wKFh0jhAbY/FoU+PPbdMOf2Ma5vh07R/IdF+N/nFg=" // Sum of ent codegen. Sum = "h1:M/M0QL1CYCUSdqGRXUrXhFYSDRJPsOOrr+RLEej/gyQ=" // Sum of ent codegen.
) )

View file

@ -241,9 +241,3 @@ func (u *User) String() string {
// Users is a parsable slice of User. // Users is a parsable slice of User.
type Users []*User type Users []*User
func (u Users) config(cfg config) {
for _i := range u {
u[_i].config = cfg
}
}

View file

@ -304,13 +304,7 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
var ( var (
_node = &User{config: uc.config} _node = &User{config: uc.config}
_spec = &sqlgraph.CreateSpec{ _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
Table: user.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
}
) )
if id, ok := uc.mutation.ID(); ok { if id, ok := uc.mutation.ID(); ok {
_node.ID = id _node.ID = id

View file

@ -40,15 +40,7 @@ func (ud *UserDelete) ExecX(ctx context.Context) int {
} }
func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) {
_spec := &sqlgraph.DeleteSpec{ _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: user.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
if ps := ud.mutation.predicates; len(ps) > 0 { if ps := ud.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {

View file

@ -228,10 +228,12 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User {
} }
// IDs executes the query and returns a list of User IDs. // IDs executes the query and returns a list of User IDs.
func (uq *UserQuery) IDs(ctx context.Context) ([]uuid.UUID, error) { func (uq *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
var ids []uuid.UUID if uq.ctx.Unique == nil && uq.path != nil {
uq.Unique(true)
}
ctx = setContextOp(ctx, uq.ctx, "IDs") ctx = setContextOp(ctx, uq.ctx, "IDs")
if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
@ -526,20 +528,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
} }
func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{ _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{ _spec.From = uq.sql
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
From: uq.sql,
Unique: true,
}
if unique := uq.ctx.Unique; unique != nil { if unique := uq.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if uq.path != nil {
_spec.Unique = true
} }
if fields := uq.ctx.Fields; len(fields) > 0 { if fields := uq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = make([]string, 0, len(fields))

View file

@ -243,16 +243,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := uu.check(); err != nil { if err := uu.check(); err != nil {
return n, err return n, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
if ps := uu.mutation.predicates; len(ps) > 0 { if ps := uu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
@ -540,6 +531,12 @@ func (uuo *UserUpdateOne) RemoveAuthTokens(a ...*AuthTokens) *UserUpdateOne {
return uuo.RemoveAuthTokenIDs(ids...) return uuo.RemoveAuthTokenIDs(ids...)
} }
// Where appends a list predicates to the UserUpdate builder.
func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
uuo.mutation.Where(ps...)
return uuo
}
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
@ -615,16 +612,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
if err := uuo.check(); err != nil { if err := uuo.check(); err != nil {
return _node, err return _node, err
} }
_spec := &sqlgraph.UpdateSpec{ _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
Node: &sqlgraph.NodeSpec{
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
id, ok := uuo.mutation.ID() id, ok := uuo.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}

View file

@ -13,7 +13,7 @@ var Files embed.FS
// It returns an error and a cleanup function. The cleanup function // It returns an error and a cleanup function. The cleanup function
// should be called when the migrations are no longer needed. // should be called when the migrations are no longer needed.
func Write(temp string) error { func Write(temp string) error {
err := os.MkdirAll(temp, 0755) err := os.MkdirAll(temp, 0o755)
if err != nil { if err != nil {
return err return err
} }
@ -33,7 +33,7 @@ func Write(temp string) error {
return err return err
} }
err = os.WriteFile(filepath.Join(temp, f.Name()), b, 0644) err = os.WriteFile(filepath.Join(temp, f.Name()), b, 0o644)
if err != nil { if err != nil {
return err return err
} }

View file

@ -14,9 +14,7 @@ import (
"github.com/hay-kot/homebox/backend/pkgs/pathlib" "github.com/hay-kot/homebox/backend/pkgs/pathlib"
) )
var ( var ErrInvalidDocExtension = errors.New("invalid document extension")
ErrInvalidDocExtension = errors.New("invalid document extension")
)
type DocumentRepository struct { type DocumentRepository struct {
db *ent.Client db *ent.Client
@ -74,7 +72,7 @@ func (r *DocumentRepository) Create(ctx context.Context, gid uuid.UUID, doc Docu
path := r.path(gid, ext) path := r.path(gid, ext)
parent := filepath.Dir(path) parent := filepath.Dir(path)
err := os.MkdirAll(parent, 0755) err := os.MkdirAll(parent, 0o755)
if err != nil { if err != nil {
return DocumentOut{}, err return DocumentOut{}, err
} }

View file

@ -34,7 +34,6 @@ func useDocs(t *testing.T, num int) []DocumentOut {
t.Cleanup(func() { t.Cleanup(func() {
for _, id := range ids { for _, id := range ids {
err := tRepos.Docs.Delete(context.Background(), id) err := tRepos.Docs.Delete(context.Background(), id)
if err != nil { if err != nil {
assert.True(t, ent.IsNotFound(err)) assert.True(t, ent.IsNotFound(err))
} }

View file

@ -76,9 +76,7 @@ type (
} }
) )
var ( var mapToGroupErr = mapTErrFunc(mapToGroup)
mapToGroupErr = mapTErrFunc(mapToGroup)
)
func mapToGroup(g *ent.Group) Group { func mapToGroup(g *ent.Group) Group {
return Group{ return Group{
@ -90,9 +88,7 @@ func mapToGroup(g *ent.Group) Group {
} }
} }
var ( var mapToGroupInvitationErr = mapTErrFunc(mapToGroupInvitation)
mapToGroupInvitationErr = mapTErrFunc(mapToGroupInvitation)
)
func mapToGroupInvitation(g *ent.GroupInvitationToken) GroupInvitation { func mapToGroupInvitation(g *ent.GroupInvitationToken) GroupInvitation {
return GroupInvitation{ return GroupInvitation{
@ -118,7 +114,6 @@ func (r *GroupRepository) StatsLocationsByPurchasePrice(ctx context.Context, GID
return sql.As(sql.Sum(t.C(item.FieldPurchasePrice)), "total") return sql.As(sql.Sum(t.C(item.FieldPurchasePrice)), "total")
}). }).
Scan(ctx, &v) Scan(ctx, &v)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -145,7 +140,6 @@ func (r *GroupRepository) StatsLabelsByPurchasePrice(ctx context.Context, GID uu
return sql.As(sql.Sum(itemTable.C(item.FieldPurchasePrice)), "total") return sql.As(sql.Sum(itemTable.C(item.FieldPurchasePrice)), "total")
}). }).
Scan(ctx, &v) Scan(ctx, &v)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -283,7 +277,6 @@ func (r *GroupRepository) InvitationCreate(ctx context.Context, groupID uuid.UUI
SetExpiresAt(invite.ExpiresAt). SetExpiresAt(invite.ExpiresAt).
SetUses(invite.Uses). SetUses(invite.Uses).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return GroupInvitation{}, err return GroupInvitation{}, err
} }

View file

@ -68,7 +68,6 @@ func (r *AttachmentRepo) Update(ctx context.Context, itemId uuid.UUID, typ attac
itm, err := r.db.Attachment.UpdateOneID(itemId). itm, err := r.db.Attachment.UpdateOneID(itemId).
SetType(typ). SetType(typ).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -58,7 +58,6 @@ func TestAttachmentRepo_Create(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got, err := tRepos.Attachments.Create(tt.args.ctx, tt.args.itemId, tt.args.docId, tt.args.typ) got, err := tRepos.Attachments.Create(tt.args.ctx, tt.args.itemId, tt.args.docId, tt.args.typ)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("AttachmentRepo.Create() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("AttachmentRepo.Create() error = %v, wantErr %v", err, tt.wantErr)
@ -119,7 +118,6 @@ func TestAttachmentRepo_Update(t *testing.T) {
assert.Equal(t, typ, updated.Type) assert.Equal(t, typ, updated.Type)
}) })
} }
} }
func TestAttachmentRepo_Delete(t *testing.T) { func TestAttachmentRepo_Delete(t *testing.T) {

View file

@ -45,7 +45,7 @@ type (
TextValue string `json:"textValue"` TextValue string `json:"textValue"`
NumberValue int `json:"numberValue"` NumberValue int `json:"numberValue"`
BooleanValue bool `json:"booleanValue"` BooleanValue bool `json:"booleanValue"`
TimeValue time.Time `json:"timeValue,omitempty"` // TimeValue time.Time `json:"timeValue,omitempty"`
} }
ItemCreate struct { ItemCreate struct {
@ -150,9 +150,7 @@ type (
} }
) )
var ( var mapItemsSummaryErr = mapTEachErrFunc(mapItemSummary)
mapItemsSummaryErr = mapTEachErrFunc(mapItemSummary)
)
func mapItemSummary(item *ent.Item) ItemSummary { func mapItemSummary(item *ent.Item) ItemSummary {
var location *LocationSummary var location *LocationSummary
@ -200,7 +198,7 @@ func mapFields(fields []*ent.ItemField) []ItemField {
TextValue: f.TextValue, TextValue: f.TextValue,
NumberValue: f.NumberValue, NumberValue: f.NumberValue,
BooleanValue: f.BooleanValue, BooleanValue: f.BooleanValue,
TimeValue: f.TimeValue, // TimeValue: f.TimeValue,
} }
} }
return result return result
@ -371,7 +369,6 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
} }
count, err := qb.Count(ctx) count, err := qb.Count(ctx)
if err != nil { if err != nil {
return PaginationResult[ItemSummary]{}, err return PaginationResult[ItemSummary]{}, err
} }
@ -387,7 +384,6 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
} }
items, err := mapItemsSummaryErr(qb.All(ctx)) items, err := mapItemsSummaryErr(qb.All(ctx))
if err != nil { if err != nil {
return PaginationResult[ItemSummary]{}, err return PaginationResult[ItemSummary]{}, err
} }
@ -398,7 +394,6 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
Total: count, Total: count,
Items: items, Items: items,
}, nil }, nil
} }
// QueryByAssetID returns items by asset ID. If the item does not exist, an error is returned. // QueryByAssetID returns items by asset ID. If the item does not exist, an error is returned.
@ -422,7 +417,6 @@ func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, ass
WithLocation(). WithLocation().
All(ctx), All(ctx),
) )
if err != nil { if err != nil {
return PaginationResult[ItemSummary]{}, err return PaginationResult[ItemSummary]{}, err
} }
@ -441,6 +435,7 @@ func (e *ItemsRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemOut,
Where(item.HasGroupWith(group.ID(gid))). Where(item.HasGroupWith(group.ID(gid))).
WithLabel(). WithLabel().
WithLocation(). WithLocation().
WithFields().
All(ctx)) All(ctx))
} }
@ -590,7 +585,7 @@ func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data
SetTextValue(f.TextValue). SetTextValue(f.TextValue).
SetNumberValue(f.NumberValue). SetNumberValue(f.NumberValue).
SetBooleanValue(f.BooleanValue). SetBooleanValue(f.BooleanValue).
SetTimeValue(f.TimeValue). // SetTimeValue(f.TimeValue).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return ItemOut{}, err return ItemOut{}, err
@ -606,8 +601,8 @@ func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data
SetName(f.Name). SetName(f.Name).
SetTextValue(f.TextValue). SetTextValue(f.TextValue).
SetNumberValue(f.NumberValue). SetNumberValue(f.NumberValue).
SetBooleanValue(f.BooleanValue). SetBooleanValue(f.BooleanValue)
SetTimeValue(f.TimeValue) // SetTimeValue(f.TimeValue)
_, err = opt.Save(ctx) _, err = opt.Save(ctx)
if err != nil { if err != nil {
@ -651,7 +646,6 @@ func (e *ItemsRepository) GetAllCustomFieldValues(ctx context.Context, GID uuid.
Unique(true). Unique(true).
Select(itemfield.FieldTextValue). Select(itemfield.FieldTextValue).
Scan(ctx, &values) Scan(ctx, &values)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get field values: %w", err) return nil, fmt.Errorf("failed to get field values: %w", err)
} }
@ -679,7 +673,6 @@ func (e *ItemsRepository) GetAllCustomFieldNames(ctx context.Context, GID uuid.U
Unique(true). Unique(true).
Select(itemfield.FieldName). Select(itemfield.FieldName).
Scan(ctx, &fields) Scan(ctx, &fields)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get custom fields: %w", err) return nil, fmt.Errorf("failed to get custom fields: %w", err)
} }

View file

@ -125,7 +125,6 @@ func TestItemsRepository_Create(t *testing.T) {
// Cleanup - Also deletes item // Cleanup - Also deletes item
err = tRepos.Locations.Delete(context.Background(), location.ID) err = tRepos.Locations.Delete(context.Background(), location.ID)
assert.NoError(t, err) assert.NoError(t, err)
} }
func TestItemsRepository_Create_Location(t *testing.T) { func TestItemsRepository_Create_Location(t *testing.T) {
@ -222,7 +221,6 @@ func TestItemsRepository_Update_Labels(t *testing.T) {
} }
}) })
} }
} }
func TestItemsRepository_Update(t *testing.T) { func TestItemsRepository_Update(t *testing.T) {

View file

@ -100,7 +100,6 @@ func (r *LabelRepository) Create(ctx context.Context, groupdId uuid.UUID, data L
SetColor(data.Color). SetColor(data.Color).
SetGroupID(groupdId). SetGroupID(groupdId).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return LabelOut{}, err return LabelOut{}, err
} }

View file

@ -62,9 +62,7 @@ func mapLocationSummary(location *ent.Location) LocationSummary {
} }
} }
var ( var mapLocationOutErr = mapTErrFunc(mapLocationOut)
mapLocationOutErr = mapTErrFunc(mapLocationOut)
)
func mapLocationOut(location *ent.Location) LocationOut { func mapLocationOut(location *ent.Location) LocationOut {
var parent *LocationSummary var parent *LocationSummary
@ -181,7 +179,6 @@ func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data Loc
} }
location, err := q.Save(ctx) location, err := q.Save(ctx)
if err != nil { if err != nil {
return LocationOut{}, err return LocationOut{}, err
} }
@ -322,7 +319,7 @@ func (lr *LocationRepository) Tree(ctx context.Context, GID uuid.UUID, tq TreeQu
} }
func ConvertLocationsToTree(locations []FlatTreeItem) []TreeItem { func ConvertLocationsToTree(locations []FlatTreeItem) []TreeItem {
var locationMap = make(map[uuid.UUID]*TreeItem, len(locations)) locationMap := make(map[uuid.UUID]*TreeItem, len(locations))
var rootIds []uuid.UUID var rootIds []uuid.UUID

View file

@ -31,7 +31,6 @@ func useLocations(t *testing.T, len int) []LocationOut {
t.Cleanup(func() { t.Cleanup(func() {
for _, loc := range out { for _, loc := range out {
err := tRepos.Locations.Delete(context.Background(), loc.ID) err := tRepos.Locations.Delete(context.Background(), loc.ID)
if err != nil { if err != nil {
assert.True(t, ent.IsNotFound(err)) assert.True(t, ent.IsNotFound(err))
} }
@ -74,7 +73,6 @@ func TestLocationRepositoryGetAllWithCount(t *testing.T) {
assert.Equal(t, 1, loc.ItemCount) assert.Equal(t, 1, loc.ItemCount)
} }
} }
} }
func TestLocationRepository_Create(t *testing.T) { func TestLocationRepository_Create(t *testing.T) {

View file

@ -93,7 +93,6 @@ func (r *MaintenanceEntryRepository) GetLog(ctx context.Context, itemID uuid.UUI
Where(maintenanceentry.ItemID(itemID)). Where(maintenanceentry.ItemID(itemID)).
Order(ent.Desc(maintenanceentry.FieldDate)). Order(ent.Desc(maintenanceentry.FieldDate)).
All(ctx) All(ctx)
if err != nil { if err != nil {
return MaintenanceLog{}, err return MaintenanceLog{}, err
} }

View file

@ -61,7 +61,6 @@ func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
// Get the log for the item // Get the log for the item
log, err := tRepos.MaintEntry.GetLog(context.Background(), item.ID) log, err := tRepos.MaintEntry.GetLog(context.Background(), item.ID)
if err != nil { if err != nil {
t.Fatalf("failed to get maintenance log: %v", err) t.Fatalf("failed to get maintenance log: %v", err)
} }

View file

@ -42,7 +42,6 @@ func (r *TokenRepository) GetUserFromToken(ctx context.Context, token []byte) (U
QueryUser(). QueryUser().
WithGroup(). WithGroup().
Only(ctx) Only(ctx)
if err != nil { if err != nil {
return UserOut{}, err return UserOut{}, err
} }
@ -59,7 +58,6 @@ func (r *TokenRepository) GetRoles(ctx context.Context, token string) (*set.Set[
authtokens.Token(tokenHash), authtokens.Token(tokenHash),
)). )).
All(ctx) All(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -80,7 +78,6 @@ func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthT
SetUserID(createToken.UserID). SetUserID(createToken.UserID).
SetExpiresAt(createToken.ExpiresAt). SetExpiresAt(createToken.ExpiresAt).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return UserAuthToken{}, err return UserAuthToken{}, err
} }
@ -90,7 +87,6 @@ func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthT
SetRole(role). SetRole(role).
SetToken(dbToken). SetToken(dbToken).
Save(ctx) Save(ctx)
if err != nil { if err != nil {
return UserAuthToken{}, err return UserAuthToken{}, err
} }
@ -115,7 +111,6 @@ func (r *TokenRepository) DeleteToken(ctx context.Context, token []byte) error {
// PurgeExpiredTokens removes all expired tokens from the database // PurgeExpiredTokens removes all expired tokens from the database
func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error) { func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error) {
tokensDeleted, err := r.db.AuthTokens.Delete().Where(authtokens.ExpiresAtLTE(time.Now())).Exec(ctx) tokensDeleted, err := r.db.AuthTokens.Delete().Where(authtokens.ExpiresAtLTE(time.Now())).Exec(ctx)
if err != nil { if err != nil {
return 0, err return 0, err
} }

View file

@ -123,7 +123,6 @@ func (e *UserRepository) DeleteAll(ctx context.Context) error {
func (e *UserRepository) GetSuperusers(ctx context.Context) ([]*ent.User, error) { func (e *UserRepository) GetSuperusers(ctx context.Context) ([]*ent.User, error) {
users, err := e.db.User.Query().Where(user.IsSuperuser(true)).All(ctx) users, err := e.db.User.Query().Where(user.IsSuperuser(true)).All(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -139,7 +139,6 @@ func TestUserRepo_Delete(t *testing.T) {
allUsers, _ = tRepos.Users.GetAll(ctx) allUsers, _ = tRepos.Users.GetAll(ctx)
assert.Equal(t, len(allUsers), 0) assert.Equal(t, len(allUsers), 0)
} }
func TestUserRepo_GetSuperusers(t *testing.T) { func TestUserRepo_GetSuperusers(t *testing.T) {

View file

@ -1,6 +1,11 @@
package types package types
import "time" import (
"errors"
"fmt"
"strings"
"time"
)
// Date is a custom type that implements the MarshalJSON interface // Date is a custom type that implements the MarshalJSON interface
// that applies date only formatting to the time.Time fields in order // that applies date only formatting to the time.Time fields in order
@ -34,18 +39,21 @@ func DateFromString(s string) Date {
return Date{} return Date{}
} }
t, err := time.Parse("2006-01-02", s) try := [...]string{
if err != nil { "2006-01-02",
// TODO: Remove - used by legacy importer "01/02/2006",
t, err = time.Parse("01/02/2006", s) time.RFC3339,
if err != nil {
return Date{}
}
} }
for _, format := range try {
t, err := time.Parse(format, s)
if err == nil {
return DateFromTime(t) return DateFromTime(t)
} }
}
return Date{}
}
func (d Date) String() string { func (d Date) String() string {
if time.Time(d).IsZero() { if time.Time(d).IsZero() {
@ -63,22 +71,35 @@ func (d Date) MarshalJSON() ([]byte, error) {
return []byte(`"` + d.String() + `"`), nil return []byte(`"` + d.String() + `"`), nil
} }
func (d *Date) UnmarshalJSON(data []byte) error { func (d *Date) UnmarshalJSON(data []byte) (err error) {
str := string(data) // unescape the string if necessary `\"` -> `"`
if str == `""` { str := strings.Trim(string(data), "\"")
fmt.Printf("str: %q\n", str)
if str == "" || str == "null" || str == `""` {
println("empty date")
*d = Date{} *d = Date{}
return nil return nil
} }
// Try YYYY-MM-DD format try := [...]string{
var t time.Time "2006-01-02",
t, err := time.Parse("2006-01-02", str) "01/02/2006",
if err != nil { time.RFC3339,
// Try default interface
err = t.UnmarshalJSON(data)
if err != nil {
return err
} }
set := false
var t time.Time
for _, format := range try {
t, err = time.Parse(format, str)
if err == nil {
set = true
break
}
}
if !set {
return errors.New("invalid date format")
} }
// strip the time and timezone information // strip the time and timezone information

View file

@ -4,10 +4,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"os"
"github.com/ardanlabs/conf/v3" "github.com/ardanlabs/conf/v3"
"os"
) )
const ( const (
@ -55,7 +54,6 @@ func New() (*Config, error) {
const prefix = "HBOX" const prefix = "HBOX"
help, err := conf.Parse(prefix, &cfg) help, err := conf.Parse(prefix, &cfg)
if err != nil { if err != nil {
if errors.Is(err, conf.ErrHelpWanted) { if errors.Is(err, conf.ErrHelpWanted) {
fmt.Println(help) fmt.Println(help)
@ -71,11 +69,9 @@ func New() (*Config, error) {
// This is useful for debugging. If the marshaller errors out, it will panic. // This is useful for debugging. If the marshaller errors out, it will panic.
func (c *Config) Print() { func (c *Config) Print() {
res, err := json.MarshalIndent(c, "", " ") res, err := json.MarshalIndent(c, "", " ")
if err != nil { if err != nil {
panic(err) panic(err)
} }
fmt.Println(string(res)) fmt.Println(string(res))
} }

View file

@ -36,5 +36,4 @@ func Test_MailerReady_Failure(t *testing.T) {
mc.From = "from" mc.From = "from"
assert.True(t, mc.Ready()) assert.True(t, mc.Ready())
} }

View file

@ -5,8 +5,7 @@ import (
"errors" "errors"
) )
type UnauthorizedError struct { type UnauthorizedError struct{}
}
func (err *UnauthorizedError) Error() string { func (err *UnauthorizedError) Error() string {
return "unauthorized" return "unauthorized"

View file

@ -14,7 +14,6 @@ func init() {
// FieldErrors array and returned. // FieldErrors array and returned.
func Check(val any) error { func Check(val any) error {
err := validate.Struct(val) err := validate.Struct(val)
if err != nil { if err != nil {
verrors, ok := err.(validator.ValidationErrors) verrors, ok := err.(validator.ValidationErrors)
if !ok { if !ok {

Some files were not shown because too many files have changed in this diff Show more