forked from mirrors/homebox
feat: chinese-currency (#158)
* run updated code gen * feat: add RMB currency support
This commit is contained in:
parent
e8f215ce34
commit
1dc1ee54e2
42 changed files with 565 additions and 1324 deletions
|
@ -73,11 +73,13 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk
|
|||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
@ -89,6 +91,8 @@ github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
|||
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
||||
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
|
|
|
@ -255,27 +255,15 @@ func (ac *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := ac.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: attachment.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(attachment.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := ac.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: attachment.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := ac.mutation.GetType(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: attachment.FieldType,
|
||||
})
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if nodes := ac.mutation.ItemIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -369,6 +369,11 @@ func (aq *AttachmentQuery) Select(fields ...string) *AttachmentSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a AttachmentSelect configured with the given aggregations.
|
||||
func (aq *AttachmentQuery) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
return aq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (aq *AttachmentQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range aq.fields {
|
||||
if !attachment.ValidColumn(f) {
|
||||
|
@ -645,8 +650,6 @@ func (agb *AttachmentGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range agb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(agb.fields)+len(agb.fns))
|
||||
for _, f := range agb.fields {
|
||||
|
@ -666,6 +669,12 @@ type AttachmentSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (as *AttachmentSelect) Aggregate(fns ...AggregateFunc) *AttachmentSelect {
|
||||
as.fns = append(as.fns, fns...)
|
||||
return as
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (as *AttachmentSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := as.prepareQuery(ctx); err != nil {
|
||||
|
@ -676,6 +685,16 @@ func (as *AttachmentSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (as *AttachmentSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(as.fns))
|
||||
for _, fn := range as.fns {
|
||||
aggregation = append(aggregation, fn(as.sql))
|
||||
}
|
||||
switch n := len(*as.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
as.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
as.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := as.sql.Query()
|
||||
if err := as.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -194,18 +194,10 @@ func (au *AttachmentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := au.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: attachment.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := au.mutation.GetType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: attachment.FieldType,
|
||||
})
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if au.mutation.ItemCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -489,18 +481,10 @@ func (auo *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
|
|||
}
|
||||
}
|
||||
if value, ok := auo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: attachment.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(attachment.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := auo.mutation.GetType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: attachment.FieldType,
|
||||
})
|
||||
_spec.SetField(attachment.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if auo.mutation.ItemCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -249,35 +249,19 @@ func (atc *AuthTokensCreate) createSpec() (*AuthTokens, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := atc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := atc.mutation.Token(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: authtokens.FieldToken,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := atc.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if nodes := atc.mutation.UserIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -333,6 +333,11 @@ func (atq *AuthTokensQuery) Select(fields ...string) *AuthTokensSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a AuthTokensSelect configured with the given aggregations.
|
||||
func (atq *AuthTokensQuery) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
return atq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (atq *AuthTokensQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range atq.fields {
|
||||
if !authtokens.ValidColumn(f) {
|
||||
|
@ -573,8 +578,6 @@ func (atgb *AuthTokensGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range atgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(atgb.fields)+len(atgb.fns))
|
||||
for _, f := range atgb.fields {
|
||||
|
@ -594,6 +597,12 @@ type AuthTokensSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ats *AuthTokensSelect) Aggregate(fns ...AggregateFunc) *AuthTokensSelect {
|
||||
ats.fns = append(ats.fns, fns...)
|
||||
return ats
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ats.prepareQuery(ctx); err != nil {
|
||||
|
@ -604,6 +613,16 @@ func (ats *AuthTokensSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (ats *AuthTokensSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ats.fns))
|
||||
for _, fn := range ats.fns {
|
||||
aggregation = append(aggregation, fn(ats.sql))
|
||||
}
|
||||
switch n := len(*ats.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ats.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ats.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ats.sql.Query()
|
||||
if err := ats.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -168,25 +168,13 @@ func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := atu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := atu.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: authtokens.FieldToken,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := atu.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if atu.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -410,25 +398,13 @@ func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens
|
|||
}
|
||||
}
|
||||
if value, ok := atuo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := atuo.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: authtokens.FieldToken,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := atuo.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: authtokens.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if atuo.mutation.UserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -250,7 +250,7 @@ func (c *AttachmentClient) DeleteOne(a *Attachment) *AttachmentDeleteOne {
|
|||
return c.DeleteOneID(a.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *AttachmentClient) DeleteOneID(id uuid.UUID) *AttachmentDeleteOne {
|
||||
builder := c.Delete().Where(attachment.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -282,7 +282,7 @@ func (c *AttachmentClient) GetX(ctx context.Context, id uuid.UUID) *Attachment {
|
|||
// QueryItem queries the item edge of a Attachment.
|
||||
func (c *AttachmentClient) QueryItem(a *Attachment) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := a.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
||||
|
@ -298,7 +298,7 @@ func (c *AttachmentClient) QueryItem(a *Attachment) *ItemQuery {
|
|||
// QueryDocument queries the document edge of a Attachment.
|
||||
func (c *AttachmentClient) QueryDocument(a *Attachment) *DocumentQuery {
|
||||
query := &DocumentQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := a.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(attachment.Table, attachment.FieldID, id),
|
||||
|
@ -372,7 +372,7 @@ func (c *AuthTokensClient) DeleteOne(at *AuthTokens) *AuthTokensDeleteOne {
|
|||
return c.DeleteOneID(at.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *AuthTokensClient) DeleteOneID(id uuid.UUID) *AuthTokensDeleteOne {
|
||||
builder := c.Delete().Where(authtokens.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -404,7 +404,7 @@ func (c *AuthTokensClient) GetX(ctx context.Context, id uuid.UUID) *AuthTokens {
|
|||
// QueryUser queries the user edge of a AuthTokens.
|
||||
func (c *AuthTokensClient) QueryUser(at *AuthTokens) *UserQuery {
|
||||
query := &UserQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := at.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(authtokens.Table, authtokens.FieldID, id),
|
||||
|
@ -478,7 +478,7 @@ func (c *DocumentClient) DeleteOne(d *Document) *DocumentDeleteOne {
|
|||
return c.DeleteOneID(d.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *DocumentClient) DeleteOneID(id uuid.UUID) *DocumentDeleteOne {
|
||||
builder := c.Delete().Where(document.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -510,7 +510,7 @@ func (c *DocumentClient) GetX(ctx context.Context, id uuid.UUID) *Document {
|
|||
// QueryGroup queries the group edge of a Document.
|
||||
func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := d.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(document.Table, document.FieldID, id),
|
||||
|
@ -526,7 +526,7 @@ func (c *DocumentClient) QueryGroup(d *Document) *GroupQuery {
|
|||
// QueryDocumentTokens queries the document_tokens edge of a Document.
|
||||
func (c *DocumentClient) QueryDocumentTokens(d *Document) *DocumentTokenQuery {
|
||||
query := &DocumentTokenQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := d.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(document.Table, document.FieldID, id),
|
||||
|
@ -542,7 +542,7 @@ func (c *DocumentClient) QueryDocumentTokens(d *Document) *DocumentTokenQuery {
|
|||
// QueryAttachments queries the attachments edge of a Document.
|
||||
func (c *DocumentClient) QueryAttachments(d *Document) *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := d.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(document.Table, document.FieldID, id),
|
||||
|
@ -616,7 +616,7 @@ func (c *DocumentTokenClient) DeleteOne(dt *DocumentToken) *DocumentTokenDeleteO
|
|||
return c.DeleteOneID(dt.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *DocumentTokenClient) DeleteOneID(id uuid.UUID) *DocumentTokenDeleteOne {
|
||||
builder := c.Delete().Where(documenttoken.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -648,7 +648,7 @@ func (c *DocumentTokenClient) GetX(ctx context.Context, id uuid.UUID) *DocumentT
|
|||
// QueryDocument queries the document edge of a DocumentToken.
|
||||
func (c *DocumentTokenClient) QueryDocument(dt *DocumentToken) *DocumentQuery {
|
||||
query := &DocumentQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := dt.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(documenttoken.Table, documenttoken.FieldID, id),
|
||||
|
@ -722,7 +722,7 @@ func (c *GroupClient) DeleteOne(gr *Group) *GroupDeleteOne {
|
|||
return c.DeleteOneID(gr.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *GroupClient) DeleteOneID(id uuid.UUID) *GroupDeleteOne {
|
||||
builder := c.Delete().Where(group.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -754,7 +754,7 @@ func (c *GroupClient) GetX(ctx context.Context, id uuid.UUID) *Group {
|
|||
// QueryUsers queries the users edge of a Group.
|
||||
func (c *GroupClient) QueryUsers(gr *Group) *UserQuery {
|
||||
query := &UserQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -770,7 +770,7 @@ func (c *GroupClient) QueryUsers(gr *Group) *UserQuery {
|
|||
// QueryLocations queries the locations edge of a Group.
|
||||
func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery {
|
||||
query := &LocationQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -786,7 +786,7 @@ func (c *GroupClient) QueryLocations(gr *Group) *LocationQuery {
|
|||
// QueryItems queries the items edge of a Group.
|
||||
func (c *GroupClient) QueryItems(gr *Group) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -802,7 +802,7 @@ func (c *GroupClient) QueryItems(gr *Group) *ItemQuery {
|
|||
// QueryLabels queries the labels edge of a Group.
|
||||
func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery {
|
||||
query := &LabelQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -818,7 +818,7 @@ func (c *GroupClient) QueryLabels(gr *Group) *LabelQuery {
|
|||
// QueryDocuments queries the documents edge of a Group.
|
||||
func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery {
|
||||
query := &DocumentQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -834,7 +834,7 @@ func (c *GroupClient) QueryDocuments(gr *Group) *DocumentQuery {
|
|||
// QueryInvitationTokens queries the invitation_tokens edge of a Group.
|
||||
func (c *GroupClient) QueryInvitationTokens(gr *Group) *GroupInvitationTokenQuery {
|
||||
query := &GroupInvitationTokenQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := gr.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
|
@ -908,7 +908,7 @@ func (c *GroupInvitationTokenClient) DeleteOne(git *GroupInvitationToken) *Group
|
|||
return c.DeleteOneID(git.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *GroupInvitationTokenClient) DeleteOneID(id uuid.UUID) *GroupInvitationTokenDeleteOne {
|
||||
builder := c.Delete().Where(groupinvitationtoken.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -940,7 +940,7 @@ func (c *GroupInvitationTokenClient) GetX(ctx context.Context, id uuid.UUID) *Gr
|
|||
// QueryGroup queries the group edge of a GroupInvitationToken.
|
||||
func (c *GroupInvitationTokenClient) QueryGroup(git *GroupInvitationToken) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := git.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(groupinvitationtoken.Table, groupinvitationtoken.FieldID, id),
|
||||
|
@ -1014,7 +1014,7 @@ func (c *ItemClient) DeleteOne(i *Item) *ItemDeleteOne {
|
|||
return c.DeleteOneID(i.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *ItemClient) DeleteOneID(id uuid.UUID) *ItemDeleteOne {
|
||||
builder := c.Delete().Where(item.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -1046,7 +1046,7 @@ func (c *ItemClient) GetX(ctx context.Context, id uuid.UUID) *Item {
|
|||
// QueryParent queries the parent edge of a Item.
|
||||
func (c *ItemClient) QueryParent(i *Item) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1062,7 +1062,7 @@ func (c *ItemClient) QueryParent(i *Item) *ItemQuery {
|
|||
// QueryChildren queries the children edge of a Item.
|
||||
func (c *ItemClient) QueryChildren(i *Item) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1078,7 +1078,7 @@ func (c *ItemClient) QueryChildren(i *Item) *ItemQuery {
|
|||
// QueryGroup queries the group edge of a Item.
|
||||
func (c *ItemClient) QueryGroup(i *Item) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1094,7 +1094,7 @@ func (c *ItemClient) QueryGroup(i *Item) *GroupQuery {
|
|||
// QueryLabel queries the label edge of a Item.
|
||||
func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
|
||||
query := &LabelQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1110,7 +1110,7 @@ func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
|
|||
// QueryLocation queries the location edge of a Item.
|
||||
func (c *ItemClient) QueryLocation(i *Item) *LocationQuery {
|
||||
query := &LocationQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1126,7 +1126,7 @@ func (c *ItemClient) QueryLocation(i *Item) *LocationQuery {
|
|||
// QueryFields queries the fields edge of a Item.
|
||||
func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
|
||||
query := &ItemFieldQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1142,7 +1142,7 @@ func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
|
|||
// QueryAttachments queries the attachments edge of a Item.
|
||||
func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
|
@ -1216,7 +1216,7 @@ func (c *ItemFieldClient) DeleteOne(_if *ItemField) *ItemFieldDeleteOne {
|
|||
return c.DeleteOneID(_if.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *ItemFieldClient) DeleteOneID(id uuid.UUID) *ItemFieldDeleteOne {
|
||||
builder := c.Delete().Where(itemfield.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -1248,7 +1248,7 @@ func (c *ItemFieldClient) GetX(ctx context.Context, id uuid.UUID) *ItemField {
|
|||
// QueryItem queries the item edge of a ItemField.
|
||||
func (c *ItemFieldClient) QueryItem(_if *ItemField) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _if.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(itemfield.Table, itemfield.FieldID, id),
|
||||
|
@ -1322,7 +1322,7 @@ func (c *LabelClient) DeleteOne(l *Label) *LabelDeleteOne {
|
|||
return c.DeleteOneID(l.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *LabelClient) DeleteOneID(id uuid.UUID) *LabelDeleteOne {
|
||||
builder := c.Delete().Where(label.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -1354,7 +1354,7 @@ func (c *LabelClient) GetX(ctx context.Context, id uuid.UUID) *Label {
|
|||
// QueryGroup queries the group edge of a Label.
|
||||
func (c *LabelClient) QueryGroup(l *Label) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
|
@ -1370,7 +1370,7 @@ func (c *LabelClient) QueryGroup(l *Label) *GroupQuery {
|
|||
// QueryItems queries the items edge of a Label.
|
||||
func (c *LabelClient) QueryItems(l *Label) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
|
@ -1444,7 +1444,7 @@ func (c *LocationClient) DeleteOne(l *Location) *LocationDeleteOne {
|
|||
return c.DeleteOneID(l.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *LocationClient) DeleteOneID(id uuid.UUID) *LocationDeleteOne {
|
||||
builder := c.Delete().Where(location.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -1476,7 +1476,7 @@ func (c *LocationClient) GetX(ctx context.Context, id uuid.UUID) *Location {
|
|||
// QueryParent queries the parent edge of a Location.
|
||||
func (c *LocationClient) QueryParent(l *Location) *LocationQuery {
|
||||
query := &LocationQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(location.Table, location.FieldID, id),
|
||||
|
@ -1492,7 +1492,7 @@ func (c *LocationClient) QueryParent(l *Location) *LocationQuery {
|
|||
// QueryChildren queries the children edge of a Location.
|
||||
func (c *LocationClient) QueryChildren(l *Location) *LocationQuery {
|
||||
query := &LocationQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(location.Table, location.FieldID, id),
|
||||
|
@ -1508,7 +1508,7 @@ func (c *LocationClient) QueryChildren(l *Location) *LocationQuery {
|
|||
// QueryGroup queries the group edge of a Location.
|
||||
func (c *LocationClient) QueryGroup(l *Location) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(location.Table, location.FieldID, id),
|
||||
|
@ -1524,7 +1524,7 @@ func (c *LocationClient) QueryGroup(l *Location) *GroupQuery {
|
|||
// QueryItems queries the items edge of a Location.
|
||||
func (c *LocationClient) QueryItems(l *Location) *ItemQuery {
|
||||
query := &ItemQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := l.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(location.Table, location.FieldID, id),
|
||||
|
@ -1598,7 +1598,7 @@ func (c *UserClient) DeleteOne(u *User) *UserDeleteOne {
|
|||
return c.DeleteOneID(u.ID)
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne {
|
||||
builder := c.Delete().Where(user.ID(id))
|
||||
builder.mutation.id = &id
|
||||
|
@ -1630,7 +1630,7 @@ func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User {
|
|||
// QueryGroup queries the group edge of a User.
|
||||
func (c *UserClient) QueryGroup(u *User) *GroupQuery {
|
||||
query := &GroupQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
|
@ -1646,7 +1646,7 @@ func (c *UserClient) QueryGroup(u *User) *GroupQuery {
|
|||
// QueryAuthTokens queries the auth_tokens edge of a User.
|
||||
func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery {
|
||||
query := &AuthTokensQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := u.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(user.Table, user.FieldID, id),
|
||||
|
|
|
@ -274,35 +274,19 @@ func (dc *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := dc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: document.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(document.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := dc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: document.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(document.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := dc.mutation.Title(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldTitle,
|
||||
})
|
||||
_spec.SetField(document.FieldTitle, field.TypeString, value)
|
||||
_node.Title = value
|
||||
}
|
||||
if value, ok := dc.mutation.Path(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldPath,
|
||||
})
|
||||
_spec.SetField(document.FieldPath, field.TypeString, value)
|
||||
_node.Path = value
|
||||
}
|
||||
if nodes := dc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -406,6 +406,11 @@ func (dq *DocumentQuery) Select(fields ...string) *DocumentSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a DocumentSelect configured with the given aggregations.
|
||||
func (dq *DocumentQuery) Aggregate(fns ...AggregateFunc) *DocumentSelect {
|
||||
return dq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (dq *DocumentQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range dq.fields {
|
||||
if !document.ValidColumn(f) {
|
||||
|
@ -724,8 +729,6 @@ func (dgb *DocumentGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range dgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(dgb.fields)+len(dgb.fns))
|
||||
for _, f := range dgb.fields {
|
||||
|
@ -745,6 +748,12 @@ type DocumentSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ds *DocumentSelect) Aggregate(fns ...AggregateFunc) *DocumentSelect {
|
||||
ds.fns = append(ds.fns, fns...)
|
||||
return ds
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ds *DocumentSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ds.prepareQuery(ctx); err != nil {
|
||||
|
@ -755,6 +764,16 @@ func (ds *DocumentSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (ds *DocumentSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ds.fns))
|
||||
for _, fn := range ds.fns {
|
||||
aggregation = append(aggregation, fn(ds.sql))
|
||||
}
|
||||
switch n := len(*ds.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ds.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ds.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ds.sql.Query()
|
||||
if err := ds.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -250,25 +250,13 @@ func (du *DocumentUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := du.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: document.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(document.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := du.mutation.Title(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldTitle,
|
||||
})
|
||||
_spec.SetField(document.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := du.mutation.Path(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldPath,
|
||||
})
|
||||
_spec.SetField(document.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if du.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -680,25 +668,13 @@ func (duo *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err
|
|||
}
|
||||
}
|
||||
if value, ok := duo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: document.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(document.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := duo.mutation.Title(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldTitle,
|
||||
})
|
||||
_spec.SetField(document.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := duo.mutation.Path(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: document.FieldPath,
|
||||
})
|
||||
_spec.SetField(document.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if duo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -275,43 +275,23 @@ func (dtc *DocumentTokenCreate) createSpec() (*DocumentToken, *sqlgraph.CreateSp
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := dtc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := dtc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := dtc.mutation.Token(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldToken, field.TypeBytes, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := dtc.mutation.Uses(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUses, field.TypeInt, value)
|
||||
_node.Uses = value
|
||||
}
|
||||
if value, ok := dtc.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldExpiresAt, field.TypeTime, value)
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if nodes := dtc.mutation.DocumentIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -333,6 +333,11 @@ func (dtq *DocumentTokenQuery) Select(fields ...string) *DocumentTokenSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a DocumentTokenSelect configured with the given aggregations.
|
||||
func (dtq *DocumentTokenQuery) Aggregate(fns ...AggregateFunc) *DocumentTokenSelect {
|
||||
return dtq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (dtq *DocumentTokenQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range dtq.fields {
|
||||
if !documenttoken.ValidColumn(f) {
|
||||
|
@ -573,8 +578,6 @@ func (dtgb *DocumentTokenGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range dtgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(dtgb.fields)+len(dtgb.fns))
|
||||
for _, f := range dtgb.fields {
|
||||
|
@ -594,6 +597,12 @@ type DocumentTokenSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (dts *DocumentTokenSelect) Aggregate(fns ...AggregateFunc) *DocumentTokenSelect {
|
||||
dts.fns = append(dts.fns, fns...)
|
||||
return dts
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (dts *DocumentTokenSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := dts.prepareQuery(ctx); err != nil {
|
||||
|
@ -604,6 +613,16 @@ func (dts *DocumentTokenSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (dts *DocumentTokenSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(dts.fns))
|
||||
for _, fn := range dts.fns {
|
||||
aggregation = append(aggregation, fn(dts.sql))
|
||||
}
|
||||
switch n := len(*dts.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
dts.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
dts.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := dts.sql.Query()
|
||||
if err := dts.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -205,39 +205,19 @@ func (dtu *DocumentTokenUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|||
}
|
||||
}
|
||||
if value, ok := dtu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := dtu.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := dtu.mutation.Uses(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dtu.mutation.AddedUses(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUses,
|
||||
})
|
||||
_spec.AddField(documenttoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dtu.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if dtu.mutation.DocumentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -498,39 +478,19 @@ func (dtuo *DocumentTokenUpdateOne) sqlSave(ctx context.Context) (_node *Documen
|
|||
}
|
||||
}
|
||||
if value, ok := dtuo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := dtuo.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := dtuo.mutation.Uses(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dtuo.mutation.AddedUses(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldUses,
|
||||
})
|
||||
_spec.AddField(documenttoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := dtuo.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: documenttoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(documenttoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if dtuo.mutation.DocumentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -283,6 +283,7 @@ func IsConstraintError(err error) bool {
|
|||
type selector struct {
|
||||
label string
|
||||
flds *[]string
|
||||
fns []AggregateFunc
|
||||
scan func(context.Context, any) error
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ const (
|
|||
CurrencySek Currency = "sek"
|
||||
CurrencyDkk Currency = "dkk"
|
||||
CurrencyInr Currency = "inr"
|
||||
CurrencyRmb Currency = "rmb"
|
||||
)
|
||||
|
||||
func (c Currency) String() string {
|
||||
|
@ -139,7 +140,7 @@ func (c Currency) String() string {
|
|||
// CurrencyValidator is a validator for the "currency" field enum values. It is called by the builders before save.
|
||||
func CurrencyValidator(c Currency) error {
|
||||
switch c {
|
||||
case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk, CurrencyInr:
|
||||
case CurrencyUsd, CurrencyEur, CurrencyGbp, CurrencyJpy, CurrencyZar, CurrencyAud, CurrencyNok, CurrencySek, CurrencyDkk, CurrencyInr, CurrencyRmb:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("group: invalid enum value for currency field: %q", c)
|
||||
|
|
|
@ -335,35 +335,19 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := gc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: group.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(group.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := gc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: group.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(group.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := gc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: group.FieldName,
|
||||
})
|
||||
_spec.SetField(group.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := gc.mutation.Currency(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: group.FieldCurrency,
|
||||
})
|
||||
_spec.SetField(group.FieldCurrency, field.TypeEnum, value)
|
||||
_node.Currency = value
|
||||
}
|
||||
if nodes := gc.mutation.UsersIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -513,6 +513,11 @@ func (gq *GroupQuery) Select(fields ...string) *GroupSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a GroupSelect configured with the given aggregations.
|
||||
func (gq *GroupQuery) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
return gq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (gq *GroupQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range gq.fields {
|
||||
if !group.ValidColumn(f) {
|
||||
|
@ -946,8 +951,6 @@ func (ggb *GroupGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range ggb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(ggb.fields)+len(ggb.fns))
|
||||
for _, f := range ggb.fields {
|
||||
|
@ -967,6 +970,12 @@ type GroupSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (gs *GroupSelect) Aggregate(fns ...AggregateFunc) *GroupSelect {
|
||||
gs.fns = append(gs.fns, fns...)
|
||||
return gs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (gs *GroupSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := gs.prepareQuery(ctx); err != nil {
|
||||
|
@ -977,6 +986,16 @@ func (gs *GroupSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (gs *GroupSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(gs.fns))
|
||||
for _, fn := range gs.fns {
|
||||
aggregation = append(aggregation, fn(gs.sql))
|
||||
}
|
||||
switch n := len(*gs.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
gs.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
gs.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := gs.sql.Query()
|
||||
if err := gs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -385,25 +385,13 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := gu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: group.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(group.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: group.FieldName,
|
||||
})
|
||||
_spec.SetField(group.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := gu.mutation.Currency(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: group.FieldCurrency,
|
||||
})
|
||||
_spec.SetField(group.FieldCurrency, field.TypeEnum, value)
|
||||
}
|
||||
if gu.mutation.UsersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -1128,25 +1116,13 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error
|
|||
}
|
||||
}
|
||||
if value, ok := guo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: group.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(group.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := guo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: group.FieldName,
|
||||
})
|
||||
_spec.SetField(group.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := guo.mutation.Currency(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: group.FieldCurrency,
|
||||
})
|
||||
_spec.SetField(group.FieldCurrency, field.TypeEnum, value)
|
||||
}
|
||||
if guo.mutation.UsersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -270,43 +270,23 @@ func (gitc *GroupInvitationTokenCreate) createSpec() (*GroupInvitationToken, *sq
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := gitc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.Token(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
_node.Token = value
|
||||
}
|
||||
if value, ok := gitc.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
_node.ExpiresAt = value
|
||||
}
|
||||
if value, ok := gitc.mutation.Uses(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
_node.Uses = value
|
||||
}
|
||||
if nodes := gitc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -333,6 +333,11 @@ func (gitq *GroupInvitationTokenQuery) Select(fields ...string) *GroupInvitation
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a GroupInvitationTokenSelect configured with the given aggregations.
|
||||
func (gitq *GroupInvitationTokenQuery) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
return gitq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (gitq *GroupInvitationTokenQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range gitq.fields {
|
||||
if !groupinvitationtoken.ValidColumn(f) {
|
||||
|
@ -573,8 +578,6 @@ func (gitgb *GroupInvitationTokenGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range gitgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(gitgb.fields)+len(gitgb.fns))
|
||||
for _, f := range gitgb.fields {
|
||||
|
@ -594,6 +597,12 @@ type GroupInvitationTokenSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (gits *GroupInvitationTokenSelect) Aggregate(fns ...AggregateFunc) *GroupInvitationTokenSelect {
|
||||
gits.fns = append(gits.fns, fns...)
|
||||
return gits
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := gits.prepareQuery(ctx); err != nil {
|
||||
|
@ -604,6 +613,16 @@ func (gits *GroupInvitationTokenSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (gits *GroupInvitationTokenSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(gits.fns))
|
||||
for _, fn := range gits.fns {
|
||||
aggregation = append(aggregation, fn(gits.sql))
|
||||
}
|
||||
switch n := len(*gits.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
gits.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
gits.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := gits.sql.Query()
|
||||
if err := gits.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -189,39 +189,19 @@ func (gitu *GroupInvitationTokenUpdate) sqlSave(ctx context.Context) (n int, err
|
|||
}
|
||||
}
|
||||
if value, ok := gitu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.Uses(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := gitu.mutation.AddedUses(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUses,
|
||||
})
|
||||
_spec.AddField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if gitu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -466,39 +446,19 @@ func (gituo *GroupInvitationTokenUpdateOne) sqlSave(ctx context.Context) (_node
|
|||
}
|
||||
}
|
||||
if value, ok := gituo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.Token(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBytes,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldToken,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldToken, field.TypeBytes, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.ExpiresAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldExpiresAt,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.Uses(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUses,
|
||||
})
|
||||
_spec.SetField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := gituo.mutation.AddedUses(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: groupinvitationtoken.FieldUses,
|
||||
})
|
||||
_spec.AddField(groupinvitationtoken.FieldUses, field.TypeInt, value)
|
||||
}
|
||||
if gituo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -699,187 +699,95 @@ func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := ic.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(item.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := ic.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(item.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := ic.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldName,
|
||||
})
|
||||
_spec.SetField(item.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := ic.mutation.Description(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldDescription,
|
||||
})
|
||||
_spec.SetField(item.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := ic.mutation.ImportRef(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldImportRef,
|
||||
})
|
||||
_spec.SetField(item.FieldImportRef, field.TypeString, value)
|
||||
_node.ImportRef = value
|
||||
}
|
||||
if value, ok := ic.mutation.Notes(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldNotes, field.TypeString, value)
|
||||
_node.Notes = value
|
||||
}
|
||||
if value, ok := ic.mutation.Quantity(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldQuantity,
|
||||
})
|
||||
_spec.SetField(item.FieldQuantity, field.TypeInt, value)
|
||||
_node.Quantity = value
|
||||
}
|
||||
if value, ok := ic.mutation.Insured(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldInsured,
|
||||
})
|
||||
_spec.SetField(item.FieldInsured, field.TypeBool, value)
|
||||
_node.Insured = value
|
||||
}
|
||||
if value, ok := ic.mutation.Archived(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldArchived,
|
||||
})
|
||||
_spec.SetField(item.FieldArchived, field.TypeBool, value)
|
||||
_node.Archived = value
|
||||
}
|
||||
if value, ok := ic.mutation.AssetID(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
_spec.SetField(item.FieldAssetID, field.TypeInt, value)
|
||||
_node.AssetID = value
|
||||
}
|
||||
if value, ok := ic.mutation.SerialNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSerialNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldSerialNumber, field.TypeString, value)
|
||||
_node.SerialNumber = value
|
||||
}
|
||||
if value, ok := ic.mutation.ModelNumber(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldModelNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldModelNumber, field.TypeString, value)
|
||||
_node.ModelNumber = value
|
||||
}
|
||||
if value, ok := ic.mutation.Manufacturer(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldManufacturer,
|
||||
})
|
||||
_spec.SetField(item.FieldManufacturer, field.TypeString, value)
|
||||
_node.Manufacturer = value
|
||||
}
|
||||
if value, ok := ic.mutation.LifetimeWarranty(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldLifetimeWarranty,
|
||||
})
|
||||
_spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value)
|
||||
_node.LifetimeWarranty = value
|
||||
}
|
||||
if value, ok := ic.mutation.WarrantyExpires(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyExpires,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value)
|
||||
_node.WarrantyExpires = value
|
||||
}
|
||||
if value, ok := ic.mutation.WarrantyDetails(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyDetails,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyDetails, field.TypeString, value)
|
||||
_node.WarrantyDetails = value
|
||||
}
|
||||
if value, ok := ic.mutation.PurchaseTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseTime,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseTime, field.TypeTime, value)
|
||||
_node.PurchaseTime = value
|
||||
}
|
||||
if value, ok := ic.mutation.PurchaseFrom(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseFrom,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseFrom, field.TypeString, value)
|
||||
_node.PurchaseFrom = value
|
||||
}
|
||||
if value, ok := ic.mutation.PurchasePrice(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldPurchasePrice,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
||||
_node.PurchasePrice = value
|
||||
}
|
||||
if value, ok := ic.mutation.SoldTime(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTime,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTime, field.TypeTime, value)
|
||||
_node.SoldTime = value
|
||||
}
|
||||
if value, ok := ic.mutation.SoldTo(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTo,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTo, field.TypeString, value)
|
||||
_node.SoldTo = value
|
||||
}
|
||||
if value, ok := ic.mutation.SoldPrice(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldSoldPrice,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value)
|
||||
_node.SoldPrice = value
|
||||
}
|
||||
if value, ok := ic.mutation.SoldNotes(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldNotes, field.TypeString, value)
|
||||
_node.SoldNotes = value
|
||||
}
|
||||
if nodes := ic.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -548,6 +548,11 @@ func (iq *ItemQuery) Select(fields ...string) *ItemSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ItemSelect configured with the given aggregations.
|
||||
func (iq *ItemQuery) Aggregate(fns ...AggregateFunc) *ItemSelect {
|
||||
return iq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (iq *ItemQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range iq.fields {
|
||||
if !item.ValidColumn(f) {
|
||||
|
@ -778,7 +783,7 @@ func (iq *ItemQuery) loadLabel(ctx context.Context, query *LabelQuery, nodes []*
|
|||
outValue := *values[0].(*uuid.UUID)
|
||||
inValue := *values[1].(*uuid.UUID)
|
||||
if nids[inValue] == nil {
|
||||
nids[inValue] = map[*Item]struct{}{byID[outValue]: struct{}{}}
|
||||
nids[inValue] = map[*Item]struct{}{byID[outValue]: {}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
|
@ -1043,8 +1048,6 @@ func (igb *ItemGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range igb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(igb.fields)+len(igb.fns))
|
||||
for _, f := range igb.fields {
|
||||
|
@ -1064,6 +1067,12 @@ type ItemSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (is *ItemSelect) Aggregate(fns ...AggregateFunc) *ItemSelect {
|
||||
is.fns = append(is.fns, fns...)
|
||||
return is
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (is *ItemSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := is.prepareQuery(ctx); err != nil {
|
||||
|
@ -1074,6 +1083,16 @@ func (is *ItemSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (is *ItemSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(is.fns))
|
||||
for _, fn := range is.fns {
|
||||
aggregation = append(aggregation, fn(is.sql))
|
||||
}
|
||||
switch n := len(*is.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
is.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
is.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := is.sql.Query()
|
||||
if err := is.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -764,257 +764,118 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := iu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(item.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldName,
|
||||
})
|
||||
_spec.SetField(item.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldDescription,
|
||||
})
|
||||
_spec.SetField(item.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(item.FieldDescription, field.TypeString)
|
||||
}
|
||||
if iu.mutation.ImportRefCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldImportRef,
|
||||
})
|
||||
_spec.ClearField(item.FieldImportRef, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.Notes(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldNotes, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.NotesCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldNotes,
|
||||
})
|
||||
_spec.ClearField(item.FieldNotes, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.Quantity(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldQuantity,
|
||||
})
|
||||
_spec.SetField(item.FieldQuantity, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedQuantity(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldQuantity,
|
||||
})
|
||||
_spec.AddField(item.FieldQuantity, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Insured(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldInsured,
|
||||
})
|
||||
_spec.SetField(item.FieldInsured, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Archived(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldArchived,
|
||||
})
|
||||
_spec.SetField(item.FieldArchived, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AssetID(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
_spec.SetField(item.FieldAssetID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedAssetID(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
_spec.AddField(item.FieldAssetID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.SerialNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSerialNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldSerialNumber, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.SerialNumberCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSerialNumber,
|
||||
})
|
||||
_spec.ClearField(item.FieldSerialNumber, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.ModelNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldModelNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldModelNumber, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.ModelNumberCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldModelNumber,
|
||||
})
|
||||
_spec.ClearField(item.FieldModelNumber, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.Manufacturer(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldManufacturer,
|
||||
})
|
||||
_spec.SetField(item.FieldManufacturer, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.ManufacturerCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldManufacturer,
|
||||
})
|
||||
_spec.ClearField(item.FieldManufacturer, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.LifetimeWarranty(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldLifetimeWarranty,
|
||||
})
|
||||
_spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iu.mutation.WarrantyExpires(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyExpires,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value)
|
||||
}
|
||||
if iu.mutation.WarrantyExpiresCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldWarrantyExpires,
|
||||
})
|
||||
_spec.ClearField(item.FieldWarrantyExpires, field.TypeTime)
|
||||
}
|
||||
if value, ok := iu.mutation.WarrantyDetails(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyDetails,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyDetails, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.WarrantyDetailsCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldWarrantyDetails,
|
||||
})
|
||||
_spec.ClearField(item.FieldWarrantyDetails, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.PurchaseTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseTime,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseTime, field.TypeTime, value)
|
||||
}
|
||||
if iu.mutation.PurchaseTimeCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldPurchaseTime,
|
||||
})
|
||||
_spec.ClearField(item.FieldPurchaseTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := iu.mutation.PurchaseFrom(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseFrom,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseFrom, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.PurchaseFromCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldPurchaseFrom,
|
||||
})
|
||||
_spec.ClearField(item.FieldPurchaseFrom, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.PurchasePrice(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldPurchasePrice,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedPurchasePrice(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldPurchasePrice,
|
||||
})
|
||||
_spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iu.mutation.SoldTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTime,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTime, field.TypeTime, value)
|
||||
}
|
||||
if iu.mutation.SoldTimeCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldSoldTime,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := iu.mutation.SoldTo(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTo,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTo, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.SoldToCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSoldTo,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldTo, field.TypeString)
|
||||
}
|
||||
if value, ok := iu.mutation.SoldPrice(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldSoldPrice,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedSoldPrice(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldSoldPrice,
|
||||
})
|
||||
_spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iu.mutation.SoldNotes(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldNotes, field.TypeString, value)
|
||||
}
|
||||
if iu.mutation.SoldNotesCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
||||
}
|
||||
if iu.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -2116,257 +1977,118 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
}
|
||||
}
|
||||
if value, ok := iuo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(item.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldName,
|
||||
})
|
||||
_spec.SetField(item.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldDescription,
|
||||
})
|
||||
_spec.SetField(item.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(item.FieldDescription, field.TypeString)
|
||||
}
|
||||
if iuo.mutation.ImportRefCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldImportRef,
|
||||
})
|
||||
_spec.ClearField(item.FieldImportRef, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.Notes(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldNotes, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.NotesCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldNotes,
|
||||
})
|
||||
_spec.ClearField(item.FieldNotes, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.Quantity(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldQuantity,
|
||||
})
|
||||
_spec.SetField(item.FieldQuantity, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedQuantity(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldQuantity,
|
||||
})
|
||||
_spec.AddField(item.FieldQuantity, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Insured(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldInsured,
|
||||
})
|
||||
_spec.SetField(item.FieldInsured, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Archived(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldArchived,
|
||||
})
|
||||
_spec.SetField(item.FieldArchived, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AssetID(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
_spec.SetField(item.FieldAssetID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedAssetID(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
_spec.AddField(item.FieldAssetID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.SerialNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSerialNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldSerialNumber, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.SerialNumberCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSerialNumber,
|
||||
})
|
||||
_spec.ClearField(item.FieldSerialNumber, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.ModelNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldModelNumber,
|
||||
})
|
||||
_spec.SetField(item.FieldModelNumber, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.ModelNumberCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldModelNumber,
|
||||
})
|
||||
_spec.ClearField(item.FieldModelNumber, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.Manufacturer(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldManufacturer,
|
||||
})
|
||||
_spec.SetField(item.FieldManufacturer, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.ManufacturerCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldManufacturer,
|
||||
})
|
||||
_spec.ClearField(item.FieldManufacturer, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.LifetimeWarranty(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: item.FieldLifetimeWarranty,
|
||||
})
|
||||
_spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.WarrantyExpires(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyExpires,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value)
|
||||
}
|
||||
if iuo.mutation.WarrantyExpiresCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldWarrantyExpires,
|
||||
})
|
||||
_spec.ClearField(item.FieldWarrantyExpires, field.TypeTime)
|
||||
}
|
||||
if value, ok := iuo.mutation.WarrantyDetails(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldWarrantyDetails,
|
||||
})
|
||||
_spec.SetField(item.FieldWarrantyDetails, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.WarrantyDetailsCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldWarrantyDetails,
|
||||
})
|
||||
_spec.ClearField(item.FieldWarrantyDetails, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.PurchaseTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseTime,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseTime, field.TypeTime, value)
|
||||
}
|
||||
if iuo.mutation.PurchaseTimeCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldPurchaseTime,
|
||||
})
|
||||
_spec.ClearField(item.FieldPurchaseTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := iuo.mutation.PurchaseFrom(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldPurchaseFrom,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchaseFrom, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.PurchaseFromCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldPurchaseFrom,
|
||||
})
|
||||
_spec.ClearField(item.FieldPurchaseFrom, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.PurchasePrice(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldPurchasePrice,
|
||||
})
|
||||
_spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedPurchasePrice(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldPurchasePrice,
|
||||
})
|
||||
_spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.SoldTime(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTime,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTime, field.TypeTime, value)
|
||||
}
|
||||
if iuo.mutation.SoldTimeCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: item.FieldSoldTime,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldTime, field.TypeTime)
|
||||
}
|
||||
if value, ok := iuo.mutation.SoldTo(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldTo,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldTo, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.SoldToCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSoldTo,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldTo, field.TypeString)
|
||||
}
|
||||
if value, ok := iuo.mutation.SoldPrice(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldSoldPrice,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedSoldPrice(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeFloat64,
|
||||
Value: value,
|
||||
Column: item.FieldSoldPrice,
|
||||
})
|
||||
_spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.SoldNotes(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
_spec.SetField(item.FieldSoldNotes, field.TypeString, value)
|
||||
}
|
||||
if iuo.mutation.SoldNotesCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: item.FieldSoldNotes,
|
||||
})
|
||||
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
||||
}
|
||||
if iuo.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -341,75 +341,39 @@ func (ifc *ItemFieldCreate) createSpec() (*ItemField, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := ifc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := ifc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := ifc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldName,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := ifc.mutation.Description(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldDescription,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := ifc.mutation.GetType(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: itemfield.FieldType,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
|
||||
_node.Type = value
|
||||
}
|
||||
if value, ok := ifc.mutation.TextValue(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTextValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
|
||||
_node.TextValue = value
|
||||
}
|
||||
if value, ok := ifc.mutation.NumberValue(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
|
||||
_node.NumberValue = value
|
||||
}
|
||||
if value, ok := ifc.mutation.BooleanValue(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: itemfield.FieldBooleanValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
|
||||
_node.BooleanValue = value
|
||||
}
|
||||
if value, ok := ifc.mutation.TimeValue(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTimeValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
|
||||
_node.TimeValue = value
|
||||
}
|
||||
if nodes := ifc.mutation.ItemIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -333,6 +333,11 @@ func (ifq *ItemFieldQuery) Select(fields ...string) *ItemFieldSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a ItemFieldSelect configured with the given aggregations.
|
||||
func (ifq *ItemFieldQuery) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
|
||||
return ifq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (ifq *ItemFieldQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range ifq.fields {
|
||||
if !itemfield.ValidColumn(f) {
|
||||
|
@ -573,8 +578,6 @@ func (ifgb *ItemFieldGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range ifgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(ifgb.fields)+len(ifgb.fns))
|
||||
for _, f := range ifgb.fields {
|
||||
|
@ -594,6 +597,12 @@ type ItemFieldSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ifs *ItemFieldSelect) Aggregate(fns ...AggregateFunc) *ItemFieldSelect {
|
||||
ifs.fns = append(ifs.fns, fns...)
|
||||
return ifs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ifs *ItemFieldSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ifs.prepareQuery(ctx); err != nil {
|
||||
|
@ -604,6 +613,16 @@ func (ifs *ItemFieldSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (ifs *ItemFieldSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ifs.fns))
|
||||
for _, fn := range ifs.fns {
|
||||
aggregation = append(aggregation, fn(ifs.sql))
|
||||
}
|
||||
switch n := len(*ifs.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ifs.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ifs.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ifs.sql.Query()
|
||||
if err := ifs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -286,85 +286,40 @@ func (ifu *ItemFieldUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := ifu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := ifu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldName,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ifu.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldDescription,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if ifu.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: itemfield.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := ifu.mutation.GetType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: itemfield.FieldType,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := ifu.mutation.TextValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTextValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if ifu.mutation.TextValueCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: itemfield.FieldTextValue,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if value, ok := ifu.mutation.NumberValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := ifu.mutation.AddedNumberValue(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if ifu.mutation.NumberValueCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
|
||||
}
|
||||
if value, ok := ifu.mutation.BooleanValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: itemfield.FieldBooleanValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := ifu.mutation.TimeValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTimeValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
|
||||
}
|
||||
if ifu.mutation.ItemCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -706,85 +661,40 @@ func (ifuo *ItemFieldUpdateOne) sqlSave(ctx context.Context) (_node *ItemField,
|
|||
}
|
||||
}
|
||||
if value, ok := ifuo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := ifuo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldName,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := ifuo.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldDescription,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if ifuo.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: itemfield.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := ifuo.mutation.GetType(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: itemfield.FieldType,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldType, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := ifuo.mutation.TextValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTextValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTextValue, field.TypeString, value)
|
||||
}
|
||||
if ifuo.mutation.TextValueCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: itemfield.FieldTextValue,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldTextValue, field.TypeString)
|
||||
}
|
||||
if value, ok := ifuo.mutation.NumberValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := ifuo.mutation.AddedNumberValue(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.AddField(itemfield.FieldNumberValue, field.TypeInt, value)
|
||||
}
|
||||
if ifuo.mutation.NumberValueCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: itemfield.FieldNumberValue,
|
||||
})
|
||||
_spec.ClearField(itemfield.FieldNumberValue, field.TypeInt)
|
||||
}
|
||||
if value, ok := ifuo.mutation.BooleanValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: itemfield.FieldBooleanValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldBooleanValue, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := ifuo.mutation.TimeValue(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: itemfield.FieldTimeValue,
|
||||
})
|
||||
_spec.SetField(itemfield.FieldTimeValue, field.TypeTime, value)
|
||||
}
|
||||
if ifuo.mutation.ItemCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -282,43 +282,23 @@ func (lc *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := lc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: label.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(label.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: label.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldName,
|
||||
})
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := lc.mutation.Description(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldDescription,
|
||||
})
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := lc.mutation.Color(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldColor,
|
||||
})
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
_node.Color = value
|
||||
}
|
||||
if nodes := lc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -370,6 +370,11 @@ func (lq *LabelQuery) Select(fields ...string) *LabelSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a LabelSelect configured with the given aggregations.
|
||||
func (lq *LabelQuery) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
return lq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (lq *LabelQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range lq.fields {
|
||||
if !label.ValidColumn(f) {
|
||||
|
@ -502,7 +507,7 @@ func (lq *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
|
|||
outValue := *values[0].(*uuid.UUID)
|
||||
inValue := *values[1].(*uuid.UUID)
|
||||
if nids[inValue] == nil {
|
||||
nids[inValue] = map[*Label]struct{}{byID[outValue]: struct{}{}}
|
||||
nids[inValue] = map[*Label]struct{}{byID[outValue]: {}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
|
@ -676,8 +681,6 @@ func (lgb *LabelGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range lgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(lgb.fields)+len(lgb.fns))
|
||||
for _, f := range lgb.fields {
|
||||
|
@ -697,6 +700,12 @@ type LabelSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ls *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
ls.fns = append(ls.fns, fns...)
|
||||
return ls
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ls *LabelSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ls.prepareQuery(ctx); err != nil {
|
||||
|
@ -707,6 +716,16 @@ func (ls *LabelSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (ls *LabelSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ls.fns))
|
||||
for _, fn := range ls.fns {
|
||||
aggregation = append(aggregation, fn(ls.sql))
|
||||
}
|
||||
switch n := len(*ls.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ls.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ls.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ls.sql.Query()
|
||||
if err := ls.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -252,44 +252,22 @@ func (lu *LabelUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := lu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: label.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldName,
|
||||
})
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldDescription,
|
||||
})
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if lu.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: label.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := lu.mutation.Color(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldColor,
|
||||
})
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if lu.mutation.ColorCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: label.FieldColor,
|
||||
})
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if lu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -650,44 +628,22 @@ func (luo *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error
|
|||
}
|
||||
}
|
||||
if value, ok := luo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: label.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldName,
|
||||
})
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldDescription,
|
||||
})
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if luo.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: label.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := luo.mutation.Color(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: label.FieldColor,
|
||||
})
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if luo.mutation.ColorCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: label.FieldColor,
|
||||
})
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if luo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -297,35 +297,19 @@ func (lc *LocationCreate) createSpec() (*Location, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := lc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: location.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(location.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: location.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := lc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldName,
|
||||
})
|
||||
_spec.SetField(location.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := lc.mutation.Description(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldDescription,
|
||||
})
|
||||
_spec.SetField(location.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if nodes := lc.mutation.ParentIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -440,6 +440,11 @@ func (lq *LocationQuery) Select(fields ...string) *LocationSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a LocationSelect configured with the given aggregations.
|
||||
func (lq *LocationQuery) Aggregate(fns ...AggregateFunc) *LocationSelect {
|
||||
return lq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (lq *LocationQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range lq.fields {
|
||||
if !location.ValidColumn(f) {
|
||||
|
@ -794,8 +799,6 @@ func (lgb *LocationGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range lgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(lgb.fields)+len(lgb.fns))
|
||||
for _, f := range lgb.fields {
|
||||
|
@ -815,6 +818,12 @@ type LocationSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ls *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect {
|
||||
ls.fns = append(ls.fns, fns...)
|
||||
return ls
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ls *LocationSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ls.prepareQuery(ctx); err != nil {
|
||||
|
@ -825,6 +834,16 @@ func (ls *LocationSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (ls *LocationSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ls.fns))
|
||||
for _, fn := range ls.fns {
|
||||
aggregation = append(aggregation, fn(ls.sql))
|
||||
}
|
||||
switch n := len(*ls.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ls.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ls.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ls.sql.Query()
|
||||
if err := ls.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -288,31 +288,16 @@ func (lu *LocationUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := lu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: location.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldName,
|
||||
})
|
||||
_spec.SetField(location.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := lu.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldDescription,
|
||||
})
|
||||
_spec.SetField(location.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if lu.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: location.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(location.FieldDescription, field.TypeString)
|
||||
}
|
||||
if lu.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -798,31 +783,16 @@ func (luo *LocationUpdateOne) sqlSave(ctx context.Context) (_node *Location, err
|
|||
}
|
||||
}
|
||||
if value, ok := luo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: location.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(location.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldName,
|
||||
})
|
||||
_spec.SetField(location.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := luo.mutation.Description(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: location.FieldDescription,
|
||||
})
|
||||
_spec.SetField(location.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if luo.mutation.DescriptionCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Column: location.FieldDescription,
|
||||
})
|
||||
_spec.ClearField(location.FieldDescription, field.TypeString)
|
||||
}
|
||||
if luo.mutation.ParentCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -127,7 +127,7 @@ var (
|
|||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr"}, Default: "usd"},
|
||||
{Name: "currency", Type: field.TypeEnum, Enums: []string{"usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr", "rmb"}, Default: "usd"},
|
||||
}
|
||||
// GroupsTable holds the schema information for the "groups" table.
|
||||
GroupsTable = &schema.Table{
|
||||
|
|
|
@ -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.3" // Version of ent codegen.
|
||||
Sum = "h1:F5FBGAWiDCGder7YT+lqMnyzXl6d0xU3xMBM/SO3CMc=" // Sum of ent codegen.
|
||||
Version = "v0.11.4" // Version of ent codegen.
|
||||
Sum = "h1:grwVY0fp31BZ6oEo3YrXenAuv8VJmEw7F/Bi6WqeH3Q=" // Sum of ent codegen.
|
||||
)
|
||||
|
|
|
@ -27,7 +27,7 @@ func (Group) Fields() []ent.Field {
|
|||
NotEmpty(),
|
||||
field.Enum("currency").
|
||||
Default("usd").
|
||||
Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr"),
|
||||
Values("usd", "eur", "gbp", "jpy", "zar", "aud", "nok", "sek", "dkk", "inr", "rmb"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,6 @@ type Tx struct {
|
|||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
|
||||
// completion callbacks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
|
@ -88,9 +82,9 @@ func (tx *Tx) Commit() error {
|
|||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), tx.onCommit...)
|
||||
tx.mu.Unlock()
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), txDriver.onCommit...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
|
@ -99,9 +93,10 @@ func (tx *Tx) Commit() error {
|
|||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onCommit = append(tx.onCommit, f)
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onCommit = append(txDriver.onCommit, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
type (
|
||||
|
@ -143,9 +138,9 @@ func (tx *Tx) Rollback() error {
|
|||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
tx.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), tx.onRollback...)
|
||||
tx.mu.Unlock()
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
|
@ -154,9 +149,10 @@ func (tx *Tx) Rollback() error {
|
|||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
tx.mu.Lock()
|
||||
defer tx.mu.Unlock()
|
||||
tx.onRollback = append(tx.onRollback, f)
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onRollback = append(txDriver.onRollback, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
|
@ -198,6 +194,10 @@ type txDriver struct {
|
|||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
// completion hooks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
|
|
|
@ -354,75 +354,39 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
|||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldCreatedAt,
|
||||
})
|
||||
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := uc.mutation.Name(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldName,
|
||||
})
|
||||
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := uc.mutation.Email(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldEmail,
|
||||
})
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
_node.Email = value
|
||||
}
|
||||
if value, ok := uc.mutation.Password(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldPassword,
|
||||
})
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
_node.Password = value
|
||||
}
|
||||
if value, ok := uc.mutation.IsSuperuser(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldIsSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||
_node.IsSuperuser = value
|
||||
}
|
||||
if value, ok := uc.mutation.Role(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: user.FieldRole,
|
||||
})
|
||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||
_node.Role = value
|
||||
}
|
||||
if value, ok := uc.mutation.Superuser(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||
_node.Superuser = value
|
||||
}
|
||||
if value, ok := uc.mutation.ActivatedOn(); ok {
|
||||
_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldActivatedOn,
|
||||
})
|
||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||
_node.ActivatedOn = value
|
||||
}
|
||||
if nodes := uc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
|
|
|
@ -370,6 +370,11 @@ func (uq *UserQuery) Select(fields ...string) *UserSelect {
|
|||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a UserSelect configured with the given aggregations.
|
||||
func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
return uq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (uq *UserQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range uq.fields {
|
||||
if !user.ValidColumn(f) {
|
||||
|
@ -649,8 +654,6 @@ func (ugb *UserGroupBy) sqlQuery() *sql.Selector {
|
|||
for _, fn := range ugb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
// If no columns were selected in a custom aggregation function, the default
|
||||
// selection is the fields used for "group-by", and the aggregation functions.
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(ugb.fields)+len(ugb.fns))
|
||||
for _, f := range ugb.fields {
|
||||
|
@ -670,6 +673,12 @@ type UserSelect struct {
|
|||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||
us.fns = append(us.fns, fns...)
|
||||
return us
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (us *UserSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := us.prepareQuery(ctx); err != nil {
|
||||
|
@ -680,6 +689,16 @@ func (us *UserSelect) Scan(ctx context.Context, v any) error {
|
|||
}
|
||||
|
||||
func (us *UserSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(us.fns))
|
||||
for _, fn := range us.fns {
|
||||
aggregation = append(aggregation, fn(us.sql))
|
||||
}
|
||||
switch n := len(*us.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
us.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
us.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := us.sql.Query()
|
||||
if err := us.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
|
|
@ -291,66 +291,31 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
}
|
||||
if value, ok := uu.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := uu.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldName,
|
||||
})
|
||||
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uu.mutation.Email(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldEmail,
|
||||
})
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uu.mutation.Password(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldPassword,
|
||||
})
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uu.mutation.IsSuperuser(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldIsSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := uu.mutation.Role(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: user.FieldRole,
|
||||
})
|
||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := uu.mutation.Superuser(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := uu.mutation.ActivatedOn(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldActivatedOn,
|
||||
})
|
||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||
}
|
||||
if uu.mutation.ActivatedOnCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: user.FieldActivatedOn,
|
||||
})
|
||||
_spec.ClearField(user.FieldActivatedOn, field.TypeTime)
|
||||
}
|
||||
if uu.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
@ -750,66 +715,31 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
|||
}
|
||||
}
|
||||
if value, ok := uuo.mutation.UpdatedAt(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldUpdatedAt,
|
||||
})
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.Name(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldName,
|
||||
})
|
||||
_spec.SetField(user.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.Email(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldEmail,
|
||||
})
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.Password(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
Value: value,
|
||||
Column: user.FieldPassword,
|
||||
})
|
||||
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.IsSuperuser(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldIsSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.Role(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeEnum,
|
||||
Value: value,
|
||||
Column: user.FieldRole,
|
||||
})
|
||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.Superuser(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeBool,
|
||||
Value: value,
|
||||
Column: user.FieldSuperuser,
|
||||
})
|
||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := uuo.mutation.ActivatedOn(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Value: value,
|
||||
Column: user.FieldActivatedOn,
|
||||
})
|
||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||
}
|
||||
if uuo.mutation.ActivatedOnCleared() {
|
||||
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeTime,
|
||||
Column: user.FieldActivatedOn,
|
||||
})
|
||||
_spec.ClearField(user.FieldActivatedOn, field.TypeTime)
|
||||
}
|
||||
if uuo.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD" | "NOK" | "SEK" | "DKK" | "INR";
|
||||
export type Codes = "USD" | "EUR" | "GBP" | "JPY" | "ZAR" | "AUD" | "NOK" | "SEK" | "DKK" | "INR" | "RMB";
|
||||
|
||||
export type Currency = {
|
||||
code: Codes;
|
||||
|
@ -20,6 +20,12 @@ export const currencies: Currency[] = [
|
|||
symbol: "£",
|
||||
name: "British Pound",
|
||||
},
|
||||
{
|
||||
code: "RMB",
|
||||
local: "zh-CN",
|
||||
symbol: "¥",
|
||||
name: "Chinese Yuan",
|
||||
},
|
||||
{
|
||||
code: "DKK",
|
||||
local: "da-DK",
|
||||
|
|
Loading…
Reference in a new issue