1
0
Fork 0

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:
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
steps:
- name: Checkout
@ -34,9 +60,5 @@ jobs:
run: pnpm install
working-directory: frontend
- name: Run linter 👀
run: pnpm lint
working-directory: "frontend"
- name: Run Integration Tests
run: task test:ci

View File

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

View File

@ -108,6 +108,16 @@ tasks:
cmds:
- 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:
desc: Runs end-to-end test on a live server (only for use in CI)
cmds:
@ -116,3 +126,12 @@ tasks:
- sleep 5
- cd frontend && pnpm run test:ci
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

@ -49,7 +49,6 @@ func (ctrl *V1Controller) HandleAssetGet() server.HandlerFunc {
return server.Respond(w, http.StatusBadRequest, "Invalid page size")
}
}
items, err := ctrl.repo.Items.QueryByAssetID(r.Context(), ctx.GID, repo.AssetID(assetId), int(page), int(pageSize))
if err != nil {

View File

@ -50,7 +50,6 @@ func (ctrl *V1Controller) HandleAuthLogin() server.HandlerFunc {
loginForm.Password = r.PostFormValue("password")
case server.ContentJSON:
err := server.Decode(r, loginForm)
if err != nil {
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)
if err != nil {
return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,8 +93,6 @@ definitions:
type: integer
textValue:
type: string
timeValue:
type: string
type:
type: string
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/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/go.mod h1:ericBi6Q8l3wBH1wEIDfKxw7rcQEuRPyBfbIzjtxJ18=
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/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/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/go.mod h1:bIacyuGeZjkTdtszdbvOcuq49VhHpV3+IPZ2ewOAK4I=
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)
assert.NoError(t, err)
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
func (svc *UserService) createSessionToken(ctx context.Context, userId uuid.UUID) (UserAuthTokenDetail, error) {
attachmentToken := hasher.GenerateToken()
attachmentData := repo.UserAuthTokenCreate{
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) {
usr, err := svc.repos.Users.GetOneEmail(ctx, username)
if err != nil {
// SECURITY: Perform hash to ensure response times are the same
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)
dbToken, err := svc.repos.AuthTokens.GetUserFromToken(ctx, hash)
if err != nil {
return UserAuthTokenDetail{}, ErrorInvalidToken
}

View File

@ -189,9 +189,3 @@ func (a *Attachment) String() string {
// Attachments is a parsable slice of 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) {
var (
_node = &Attachment{config: ac.config}
_spec = &sqlgraph.CreateSpec{
Table: attachment.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
)
if id, ok := ac.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(attachment.Table, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
if ps := ad.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (aq *AttachmentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (aq *AttachmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if aq.ctx.Unique == nil && aq.path != nil {
aq.Unique(true)
}
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 ids, nil
@ -525,20 +527,12 @@ func (aq *AttachmentQuery) sqlCount(ctx context.Context) (int, error) {
}
func (aq *AttachmentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
From: aq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
_spec.From = aq.sql
if unique := aq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if aq.path != nil {
_spec.Unique = true
}
if fields := aq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
if ps := au.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -318,6 +309,12 @@ func (auo *AttachmentUpdateOne) ClearDocument() *AttachmentUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: attachment.Table,
Columns: attachment.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: attachment.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(attachment.Table, attachment.Columns, sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID))
id, ok := auo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &AuthRoles{config: arc.config}
_spec = &sqlgraph.CreateSpec{
Table: authroles.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
)
if value, ok := arc.mutation.Role(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(authroles.Table, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
if ps := ard.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (arq *AuthRolesQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
func (arq *AuthRolesQuery) IDs(ctx context.Context) (ids []int, err error) {
if arq.ctx.Unique == nil && arq.path != nil {
arq.Unique(true)
}
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 ids, nil
@ -450,20 +452,12 @@ func (arq *AuthRolesQuery) sqlCount(ctx context.Context) (int, error) {
}
func (arq *AuthRolesQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
From: arq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
_spec.From = arq.sql
if unique := arq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if arq.path != nil {
_spec.Unique = true
}
if fields := arq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
if ps := aru.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -233,6 +224,12 @@ func (aruo *AuthRolesUpdateOne) ClearToken() *AuthRolesUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: authroles.Table,
Columns: authroles.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: authroles.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(authroles.Table, authroles.Columns, sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt))
id, ok := aruo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &AuthTokens{config: atc.config}
_spec = &sqlgraph.CreateSpec{
Table: authtokens.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
)
if id, ok := atc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(authtokens.Table, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
if ps := atd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (atq *AuthTokensQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (atq *AuthTokensQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if atq.ctx.Unique == nil && atq.path != nil {
atq.Unique(true)
}
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 ids, nil
@ -522,20 +524,12 @@ func (atq *AuthTokensQuery) sqlCount(ctx context.Context) (int, error) {
}
func (atq *AuthTokensQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
From: atq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
_spec.From = atq.sql
if unique := atq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if atq.path != nil {
_spec.Unique = true
}
if fields := atq.ctx.Fields; len(fields) > 0 {
_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) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
if ps := atu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -346,6 +337,12 @@ func (atuo *AuthTokensUpdateOne) ClearRoles() *AuthTokensUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: authtokens.Table,
Columns: authtokens.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: authtokens.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
id, ok := atuo.mutation.ID()
if !ok {
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...)
}
// 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())))`.
func (c *AttachmentClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *AuthRolesClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *AuthTokensClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *DocumentClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *GroupClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *GroupInvitationTokenClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *ItemClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *ItemFieldClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *LabelClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *LocationClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *MaintenanceEntryClient) Intercept(interceptors ...Interceptor) {
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...)
}
// 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())))`.
func (c *UserClient) Intercept(interceptors ...Interceptor) {
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.
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) {
var (
_node = &Document{config: dc.config}
_spec = &sqlgraph.CreateSpec{
Table: document.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(document.Table, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
)
if id, ok := dc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: document.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(document.Table, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
if ps := dd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (dq *DocumentQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (dq *DocumentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if dq.ctx.Unique == nil && dq.path != nil {
dq.Unique(true)
}
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 ids, nil
@ -526,20 +528,12 @@ func (dq *DocumentQuery) sqlCount(ctx context.Context) (int, error) {
}
func (dq *DocumentQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
From: dq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
_spec.From = dq.sql
if unique := dq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if dq.path != nil {
_spec.Unique = true
}
if fields := dq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
if ps := du.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -376,6 +367,12 @@ func (duo *DocumentUpdateOne) RemoveAttachments(a ...*Attachment) *DocumentUpdat
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: document.Table,
Columns: document.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: document.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(document.Table, document.Columns, sqlgraph.NewFieldSpec(document.FieldID, field.TypeUUID))
id, ok := duo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &Group{config: gc.config}
_spec = &sqlgraph.CreateSpec{
Table: group.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
)
if id, ok := gc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: group.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(group.Table, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
if ps := gd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (gq *GroupQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (gq *GroupQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if gq.ctx.Unique == nil && gq.path != nil {
gq.Unique(true)
}
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 ids, nil
@ -820,20 +822,12 @@ func (gq *GroupQuery) sqlCount(ctx context.Context) (int, error) {
}
func (gq *GroupQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
From: gq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
_spec.From = gq.sql
if unique := gq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if gq.path != nil {
_spec.Unique = true
}
if fields := gq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
if ps := gu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -954,6 +945,12 @@ func (guo *GroupUpdateOne) RemoveInvitationTokens(g ...*GroupInvitationToken) *G
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: group.Table,
Columns: group.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: group.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(group.Table, group.Columns, sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID))
id, ok := guo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &GroupInvitationToken{config: gitc.config}
_spec = &sqlgraph.CreateSpec{
Table: groupinvitationtoken.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
)
if id, ok := gitc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(groupinvitationtoken.Table, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
if ps := gitd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (gitq *GroupInvitationTokenQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if gitq.ctx.Unique == nil && gitq.path != nil {
gitq.Unique(true)
}
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 ids, nil
@ -450,20 +452,12 @@ func (gitq *GroupInvitationTokenQuery) sqlCount(ctx context.Context) (int, error
}
func (gitq *GroupInvitationTokenQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
From: gitq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
_spec.From = gitq.sql
if unique := gitq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if gitq.path != nil {
_spec.Unique = true
}
if fields := gitq.ctx.Fields; len(fields) > 0 {
_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) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
if ps := gitu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -308,6 +299,12 @@ func (gituo *GroupInvitationTokenUpdateOne) ClearGroup() *GroupInvitationTokenUp
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.
// The default is selecting all fields defined in the entity schema.
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) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: groupinvitationtoken.Table,
Columns: groupinvitationtoken.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: groupinvitationtoken.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(groupinvitationtoken.Table, groupinvitationtoken.Columns, sqlgraph.NewFieldSpec(groupinvitationtoken.FieldID, field.TypeUUID))
id, ok := gituo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &Item{config: ic.config}
_spec = &sqlgraph.CreateSpec{
Table: item.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
)
if id, ok := ic.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: item.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(item.Table, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
if ps := id.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (iq *ItemQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (iq *ItemQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if iq.ctx.Unique == nil && iq.path != nil {
iq.Unique(true)
}
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 ids, nil
@ -1000,20 +1002,12 @@ func (iq *ItemQuery) sqlCount(ctx context.Context) (int, error) {
}
func (iq *ItemQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
From: iq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
_spec.From = iq.sql
if unique := iq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if iq.path != nil {
_spec.Unique = true
}
if fields := iq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
if ps := iu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -1909,6 +1900,12 @@ func (iuo *ItemUpdateOne) RemoveAttachments(a ...*Attachment) *ItemUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: item.Table,
Columns: item.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: item.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
id, ok := iuo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &ItemField{config: ifc.config}
_spec = &sqlgraph.CreateSpec{
Table: itemfield.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
)
if id, ok := ifc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(itemfield.Table, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
if ps := ifd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (ifq *ItemFieldQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (ifq *ItemFieldQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if ifq.ctx.Unique == nil && ifq.path != nil {
ifq.Unique(true)
}
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 ids, nil
@ -450,20 +452,12 @@ func (ifq *ItemFieldQuery) sqlCount(ctx context.Context) (int, error) {
}
func (ifq *ItemFieldQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
From: ifq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
_spec.From = ifq.sql
if unique := ifq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if ifq.path != nil {
_spec.Unique = true
}
if fields := ifq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
if ps := ifu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -489,6 +480,12 @@ func (ifuo *ItemFieldUpdateOne) ClearItem() *ItemFieldUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: itemfield.Table,
Columns: itemfield.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: itemfield.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(itemfield.Table, itemfield.Columns, sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID))
id, ok := ifuo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &Label{config: lc.config}
_spec = &sqlgraph.CreateSpec{
Table: label.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
)
if id, ok := lc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: label.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
if ps := ld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (lq *LabelQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (lq *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
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 ids, nil
@ -556,20 +558,12 @@ func (lq *LabelQuery) sqlCount(ctx context.Context) (int, error) {
}
func (lq *LabelQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
From: lq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
_spec.From = lq.sql
if unique := lq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if lq.path != nil {
_spec.Unique = true
}
if fields := lq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
if ps := lu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -458,6 +449,12 @@ func (luo *LabelUpdateOne) RemoveItems(i ...*Item) *LabelUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: label.Table,
Columns: label.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: label.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
id, ok := luo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &Location{config: lc.config}
_spec = &sqlgraph.CreateSpec{
Table: location.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
)
if id, ok := lc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: location.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(location.Table, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
if ps := ld.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (lq *LocationQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (lq *LocationQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if lq.ctx.Unique == nil && lq.path != nil {
lq.Unique(true)
}
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 ids, nil
@ -674,20 +676,12 @@ func (lq *LocationQuery) sqlCount(ctx context.Context) (int, error) {
}
func (lq *LocationQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
From: lq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
_spec.From = lq.sql
if unique := lq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if lq.path != nil {
_spec.Unique = true
}
if fields := lq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
if ps := lu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -618,6 +609,12 @@ func (luo *LocationUpdateOne) RemoveItems(i ...*Item) *LocationUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: location.Table,
Columns: location.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: location.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(location.Table, location.Columns, sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID))
id, ok := luo.mutation.ID()
if !ok {
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.
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) {
var (
_node = &MaintenanceEntry{config: mec.config}
_spec = &sqlgraph.CreateSpec{
Table: maintenanceentry.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
)
if id, ok := mec.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
if ps := med.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (meq *MaintenanceEntryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if meq.ctx.Unique == nil && meq.path != nil {
meq.Unique(true)
}
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 ids, nil
@ -439,20 +441,12 @@ func (meq *MaintenanceEntryQuery) sqlCount(ctx context.Context) (int, error) {
}
func (meq *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
From: meq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
_spec.From = meq.sql
if unique := meq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if meq.path != nil {
_spec.Unique = true
}
if fields := meq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
if ps := meu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -359,6 +350,12 @@ func (meuo *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: maintenanceentry.Table,
Columns: maintenanceentry.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: maintenanceentry.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(maintenanceentry.Table, maintenanceentry.Columns, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
id, ok := meuo.mutation.ID()
if !ok {
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
const (
Version = "v0.11.7" // Version of ent codegen.
Sum = "h1:V+wKFh0jhAbY/FoU+PPbdMOf2Ma5vh07R/IdF+N/nFg=" // Sum of ent codegen.
Version = "v0.11.8" // Version 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.
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) {
var (
_node = &User{config: uc.config}
_spec = &sqlgraph.CreateSpec{
Table: user.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
}
_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
)
if id, ok := uc.mutation.ID(); ok {
_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) {
_spec := &sqlgraph.DeleteSpec{
Node: &sqlgraph.NodeSpec{
Table: user.Table,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
_spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
if ps := ud.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
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.
func (uq *UserQuery) IDs(ctx context.Context) ([]uuid.UUID, error) {
var ids []uuid.UUID
func (uq *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
if uq.ctx.Unique == nil && uq.path != nil {
uq.Unique(true)
}
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 ids, nil
@ -526,20 +528,12 @@ func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
}
func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
_spec := &sqlgraph.QuerySpec{
Node: &sqlgraph.NodeSpec{
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
From: uq.sql,
Unique: true,
}
_spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
_spec.From = uq.sql
if unique := uq.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if uq.path != nil {
_spec.Unique = true
}
if fields := uq.ctx.Fields; len(fields) > 0 {
_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 {
return n, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
if ps := uu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@ -540,6 +531,12 @@ func (uuo *UserUpdateOne) RemoveAuthTokens(a ...*AuthTokens) *UserUpdateOne {
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.
// The default is selecting all fields defined in the entity schema.
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 {
return _node, err
}
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
Table: user.Table,
Columns: user.Columns,
ID: &sqlgraph.FieldSpec{
Type: field.TypeUUID,
Column: user.FieldID,
},
},
}
_spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID))
id, ok := uuo.mutation.ID()
if !ok {
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
// should be called when the migrations are no longer needed.
func Write(temp string) error {
err := os.MkdirAll(temp, 0755)
err := os.MkdirAll(temp, 0o755)
if err != nil {
return err
}
@ -33,7 +33,7 @@ func Write(temp string) error {
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 {
return err
}

View File

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

View File

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

View File

@ -76,9 +76,7 @@ type (
}
)
var (
mapToGroupErr = mapTErrFunc(mapToGroup)
)
var mapToGroupErr = mapTErrFunc(mapToGroup)
func mapToGroup(g *ent.Group) Group {
return Group{
@ -90,9 +88,7 @@ func mapToGroup(g *ent.Group) Group {
}
}
var (
mapToGroupInvitationErr = mapTErrFunc(mapToGroupInvitation)
)
var mapToGroupInvitationErr = mapTErrFunc(mapToGroupInvitation)
func mapToGroupInvitation(g *ent.GroupInvitationToken) 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")
}).
Scan(ctx, &v)
if err != nil {
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")
}).
Scan(ctx, &v)
if err != nil {
return nil, err
}
@ -283,7 +277,6 @@ func (r *GroupRepository) InvitationCreate(ctx context.Context, groupID uuid.UUI
SetExpiresAt(invite.ExpiresAt).
SetUses(invite.Uses).
Save(ctx)
if err != nil {
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).
SetType(typ).
Save(ctx)
if err != nil {
return nil, err
}

View File

@ -58,7 +58,6 @@ func TestAttachmentRepo_Create(t *testing.T) {
}
for _, tt := range tests {
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)
if (err != nil) != 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)
})
}
}
func TestAttachmentRepo_Delete(t *testing.T) {

View File

@ -45,7 +45,7 @@ type (
TextValue string `json:"textValue"`
NumberValue int `json:"numberValue"`
BooleanValue bool `json:"booleanValue"`
TimeValue time.Time `json:"timeValue,omitempty"`
// TimeValue time.Time `json:"timeValue,omitempty"`
}
ItemCreate struct {
@ -150,9 +150,7 @@ type (
}
)
var (
mapItemsSummaryErr = mapTEachErrFunc(mapItemSummary)
)
var mapItemsSummaryErr = mapTEachErrFunc(mapItemSummary)
func mapItemSummary(item *ent.Item) ItemSummary {
var location *LocationSummary
@ -200,7 +198,7 @@ func mapFields(fields []*ent.ItemField) []ItemField {
TextValue: f.TextValue,
NumberValue: f.NumberValue,
BooleanValue: f.BooleanValue,
TimeValue: f.TimeValue,
// TimeValue: f.TimeValue,
}
}
return result
@ -371,7 +369,6 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
}
count, err := qb.Count(ctx)
if err != nil {
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))
if err != nil {
return PaginationResult[ItemSummary]{}, err
}
@ -398,7 +394,6 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
Total: count,
Items: items,
}, nil
}
// 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().
All(ctx),
)
if err != nil {
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))).
WithLabel().
WithLocation().
WithFields().
All(ctx))
}
@ -590,7 +585,7 @@ func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data
SetTextValue(f.TextValue).
SetNumberValue(f.NumberValue).
SetBooleanValue(f.BooleanValue).
SetTimeValue(f.TimeValue).
// SetTimeValue(f.TimeValue).
Save(ctx)
if err != nil {
return ItemOut{}, err
@ -606,8 +601,8 @@ func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data
SetName(f.Name).
SetTextValue(f.TextValue).
SetNumberValue(f.NumberValue).
SetBooleanValue(f.BooleanValue).
SetTimeValue(f.TimeValue)
SetBooleanValue(f.BooleanValue)
// SetTimeValue(f.TimeValue)
_, err = opt.Save(ctx)
if err != nil {
@ -651,7 +646,6 @@ func (e *ItemsRepository) GetAllCustomFieldValues(ctx context.Context, GID uuid.
Unique(true).
Select(itemfield.FieldTextValue).
Scan(ctx, &values)
if err != nil {
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).
Select(itemfield.FieldName).
Scan(ctx, &fields)
if err != nil {
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
err = tRepos.Locations.Delete(context.Background(), location.ID)
assert.NoError(t, err)
}
func TestItemsRepository_Create_Location(t *testing.T) {
@ -222,7 +221,6 @@ func TestItemsRepository_Update_Labels(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).
SetGroupID(groupdId).
Save(ctx)
if err != nil {
return LabelOut{}, err
}

View File

@ -62,9 +62,7 @@ func mapLocationSummary(location *ent.Location) LocationSummary {
}
}
var (
mapLocationOutErr = mapTErrFunc(mapLocationOut)
)
var mapLocationOutErr = mapTErrFunc(mapLocationOut)
func mapLocationOut(location *ent.Location) LocationOut {
var parent *LocationSummary
@ -181,7 +179,6 @@ func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data Loc
}
location, err := q.Save(ctx)
if err != nil {
return LocationOut{}, err
}
@ -322,7 +319,7 @@ func (lr *LocationRepository) Tree(ctx context.Context, GID uuid.UUID, tq TreeQu
}
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

View File

@ -31,7 +31,6 @@ func useLocations(t *testing.T, len int) []LocationOut {
t.Cleanup(func() {
for _, loc := range out {
err := tRepos.Locations.Delete(context.Background(), loc.ID)
if err != nil {
assert.True(t, ent.IsNotFound(err))
}
@ -74,7 +73,6 @@ func TestLocationRepositoryGetAllWithCount(t *testing.T) {
assert.Equal(t, 1, loc.ItemCount)
}
}
}
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)).
Order(ent.Desc(maintenanceentry.FieldDate)).
All(ctx)
if err != nil {
return MaintenanceLog{}, err
}

View File

@ -61,7 +61,6 @@ func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
// Get the log for the item
log, err := tRepos.MaintEntry.GetLog(context.Background(), item.ID)
if err != nil {
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().
WithGroup().
Only(ctx)
if err != nil {
return UserOut{}, err
}
@ -59,7 +58,6 @@ func (r *TokenRepository) GetRoles(ctx context.Context, token string) (*set.Set[
authtokens.Token(tokenHash),
)).
All(ctx)
if err != nil {
return nil, err
}
@ -80,7 +78,6 @@ func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthT
SetUserID(createToken.UserID).
SetExpiresAt(createToken.ExpiresAt).
Save(ctx)
if err != nil {
return UserAuthToken{}, err
}
@ -90,7 +87,6 @@ func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthT
SetRole(role).
SetToken(dbToken).
Save(ctx)
if err != nil {
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
func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error) {
tokensDeleted, err := r.db.AuthTokens.Delete().Where(authtokens.ExpiresAtLTE(time.Now())).Exec(ctx)
if err != nil {
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) {
users, err := e.db.User.Query().Where(user.IsSuperuser(true)).All(ctx)
if err != nil {
return nil, err
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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