mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-21 13:23:14 +01:00
* ent re-generation
* add oidc integration
* document oidc integration
* go fmt
* address backend linter findings
* run prettier on index.vue
* State cookie domain can mismatch when Hostname override is used (breaks CSRF check). Add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Delete state cookie with matching domain and MaxAge; add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix endpoint path in comments and error to include /api/v1.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Also use request context when verifying the ID token.
* Do not return raw auth errors to clients (user-enumeration risk).
* consistently set cookie the same way across function
* remove baseURL after declaration
* only enable OIDC routes if OIDC is enabled
* swagger doc for failure
* Only block when provider=local; move the check after parsing provider
* fix extended session comment
* reduce pii logging
* futher reduce pii logging
* remove unused DiscoveryDocument
* remove unused offline_access from default oidc scopes
* remove offline access from AuthCodeURL
* support host from X-Forwarded-Host
* set sane default claim names if unset
* error strings should not be capitalized
* Revert "run prettier on index.vue"
This reverts commit aa22330a23.
* Add timeout to provider discovery
* Split scopes robustly
* refactor hostname calculation
* address frontend prettier findings
* add property oidc on type APISummary
* LoginOIDC: Normalize inputs, only create if not found
* add oidc email verification
* oidc handleCallback: clear state cookie before each return
* add support for oidc nonce parameter
* Harden first-login race: handle concurrent creates gracefully and fix log key.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* support email verified claim as bool or string
* fail fast on empty email
* PKCE verifier
* fix: add timing delay to attachment test to resolve CI race condition
The attachment test was failing intermittently in CI due to a race condition
between attachment creation and retrieval. Adding a small 100ms delay after
attachment creation ensures the file system and database operations complete
before the test attempts to verify the attachment exists.
* Revert "fix: add timing delay to attachment test to resolve CI race condition"
This reverts commit 4aa8b2a0d829753e8d2dd1ba76f4b1e04e28c45e.
* oidc error state, use ref
* rename oidc.force to oidc.authRedirect
* remove hardcoded oidc error timeout
* feat: sub/iss based identity matching and userinfo endpoint collection
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
2512 lines
74 KiB
Go
Generated
2512 lines
74 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
|
)
|
|
|
|
// ItemUpdate is the builder for updating Item entities.
|
|
type ItemUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ItemMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the ItemUpdate builder.
|
|
func (_u *ItemUpdate) Where(ps ...predicate.Item) *ItemUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ItemUpdate) SetUpdatedAt(v time.Time) *ItemUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *ItemUpdate) SetName(v string) *ItemUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableName(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *ItemUpdate) SetDescription(v string) *ItemUpdate {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableDescription(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *ItemUpdate) ClearDescription() *ItemUpdate {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (_u *ItemUpdate) SetImportRef(v string) *ItemUpdate {
|
|
_u.mutation.SetImportRef(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableImportRef(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetImportRef(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (_u *ItemUpdate) ClearImportRef() *ItemUpdate {
|
|
_u.mutation.ClearImportRef()
|
|
return _u
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (_u *ItemUpdate) SetNotes(v string) *ItemUpdate {
|
|
_u.mutation.SetNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableNotes(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (_u *ItemUpdate) ClearNotes() *ItemUpdate {
|
|
_u.mutation.ClearNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *ItemUpdate) SetQuantity(v int) *ItemUpdate {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableQuantity(v *int) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *ItemUpdate) AddQuantity(v int) *ItemUpdate {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (_u *ItemUpdate) SetInsured(v bool) *ItemUpdate {
|
|
_u.mutation.SetInsured(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableInsured(v *bool) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetInsured(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (_u *ItemUpdate) SetArchived(v bool) *ItemUpdate {
|
|
_u.mutation.SetArchived(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableArchived(v *bool) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetArchived(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (_u *ItemUpdate) SetAssetID(v int) *ItemUpdate {
|
|
_u.mutation.ResetAssetID()
|
|
_u.mutation.SetAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableAssetID(v *int) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetAssetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAssetID adds value to the "asset_id" field.
|
|
func (_u *ItemUpdate) AddAssetID(v int) *ItemUpdate {
|
|
_u.mutation.AddAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSyncChildItemsLocations sets the "sync_child_items_locations" field.
|
|
func (_u *ItemUpdate) SetSyncChildItemsLocations(v bool) *ItemUpdate {
|
|
_u.mutation.SetSyncChildItemsLocations(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSyncChildItemsLocations sets the "sync_child_items_locations" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSyncChildItemsLocations(v *bool) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSyncChildItemsLocations(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (_u *ItemUpdate) SetSerialNumber(v string) *ItemUpdate {
|
|
_u.mutation.SetSerialNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSerialNumber(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSerialNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (_u *ItemUpdate) ClearSerialNumber() *ItemUpdate {
|
|
_u.mutation.ClearSerialNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (_u *ItemUpdate) SetModelNumber(v string) *ItemUpdate {
|
|
_u.mutation.SetModelNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableModelNumber(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetModelNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (_u *ItemUpdate) ClearModelNumber() *ItemUpdate {
|
|
_u.mutation.ClearModelNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (_u *ItemUpdate) SetManufacturer(v string) *ItemUpdate {
|
|
_u.mutation.SetManufacturer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableManufacturer(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetManufacturer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (_u *ItemUpdate) ClearManufacturer() *ItemUpdate {
|
|
_u.mutation.ClearManufacturer()
|
|
return _u
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (_u *ItemUpdate) SetLifetimeWarranty(v bool) *ItemUpdate {
|
|
_u.mutation.SetLifetimeWarranty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableLifetimeWarranty(v *bool) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetLifetimeWarranty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (_u *ItemUpdate) SetWarrantyExpires(v time.Time) *ItemUpdate {
|
|
_u.mutation.SetWarrantyExpires(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableWarrantyExpires(v *time.Time) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetWarrantyExpires(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (_u *ItemUpdate) ClearWarrantyExpires() *ItemUpdate {
|
|
_u.mutation.ClearWarrantyExpires()
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (_u *ItemUpdate) SetWarrantyDetails(v string) *ItemUpdate {
|
|
_u.mutation.SetWarrantyDetails(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableWarrantyDetails(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetWarrantyDetails(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (_u *ItemUpdate) ClearWarrantyDetails() *ItemUpdate {
|
|
_u.mutation.ClearWarrantyDetails()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (_u *ItemUpdate) SetPurchaseTime(v time.Time) *ItemUpdate {
|
|
_u.mutation.SetPurchaseTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillablePurchaseTime(v *time.Time) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetPurchaseTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (_u *ItemUpdate) ClearPurchaseTime() *ItemUpdate {
|
|
_u.mutation.ClearPurchaseTime()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (_u *ItemUpdate) SetPurchaseFrom(v string) *ItemUpdate {
|
|
_u.mutation.SetPurchaseFrom(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillablePurchaseFrom(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetPurchaseFrom(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (_u *ItemUpdate) ClearPurchaseFrom() *ItemUpdate {
|
|
_u.mutation.ClearPurchaseFrom()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (_u *ItemUpdate) SetPurchasePrice(v float64) *ItemUpdate {
|
|
_u.mutation.ResetPurchasePrice()
|
|
_u.mutation.SetPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillablePurchasePrice(v *float64) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetPurchasePrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPurchasePrice adds value to the "purchase_price" field.
|
|
func (_u *ItemUpdate) AddPurchasePrice(v float64) *ItemUpdate {
|
|
_u.mutation.AddPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (_u *ItemUpdate) SetSoldTime(v time.Time) *ItemUpdate {
|
|
_u.mutation.SetSoldTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSoldTime(v *time.Time) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSoldTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (_u *ItemUpdate) ClearSoldTime() *ItemUpdate {
|
|
_u.mutation.ClearSoldTime()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (_u *ItemUpdate) SetSoldTo(v string) *ItemUpdate {
|
|
_u.mutation.SetSoldTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSoldTo(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSoldTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (_u *ItemUpdate) ClearSoldTo() *ItemUpdate {
|
|
_u.mutation.ClearSoldTo()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (_u *ItemUpdate) SetSoldPrice(v float64) *ItemUpdate {
|
|
_u.mutation.ResetSoldPrice()
|
|
_u.mutation.SetSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSoldPrice(v *float64) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSoldPrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSoldPrice adds value to the "sold_price" field.
|
|
func (_u *ItemUpdate) AddSoldPrice(v float64) *ItemUpdate {
|
|
_u.mutation.AddSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (_u *ItemUpdate) SetSoldNotes(v string) *ItemUpdate {
|
|
_u.mutation.SetSoldNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableSoldNotes(v *string) *ItemUpdate {
|
|
if v != nil {
|
|
_u.SetSoldNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (_u *ItemUpdate) ClearSoldNotes() *ItemUpdate {
|
|
_u.mutation.ClearSoldNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *ItemUpdate) SetGroupID(id uuid.UUID) *ItemUpdate {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *ItemUpdate) SetGroup(v *Group) *ItemUpdate {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Item entity by ID.
|
|
func (_u *ItemUpdate) SetParentID(id uuid.UUID) *ItemUpdate {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Item entity by ID if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableParentID(id *uuid.UUID) *ItemUpdate {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Item entity.
|
|
func (_u *ItemUpdate) SetParent(v *Item) *ItemUpdate {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Item entity by IDs.
|
|
func (_u *ItemUpdate) AddChildIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Item entity.
|
|
func (_u *ItemUpdate) AddChildren(v ...*Item) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (_u *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.AddLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (_u *ItemUpdate) AddLabel(v ...*Label) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Location entity by ID.
|
|
func (_u *ItemUpdate) SetLocationID(id uuid.UUID) *ItemUpdate {
|
|
_u.mutation.SetLocationID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
|
|
func (_u *ItemUpdate) SetNillableLocationID(id *uuid.UUID) *ItemUpdate {
|
|
if id != nil {
|
|
_u = _u.SetLocationID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Location entity.
|
|
func (_u *ItemUpdate) SetLocation(v *Location) *ItemUpdate {
|
|
return _u.SetLocationID(v.ID)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the ItemField entity by IDs.
|
|
func (_u *ItemUpdate) AddFieldIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.AddFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the ItemField entity.
|
|
func (_u *ItemUpdate) AddFields(v ...*ItemField) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (_u *ItemUpdate) AddMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *ItemUpdate) AddMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (_u *ItemUpdate) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.AddAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (_u *ItemUpdate) AddAttachments(v ...*Attachment) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ItemMutation object of the builder.
|
|
func (_u *ItemUpdate) Mutation() *ItemMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *ItemUpdate) ClearGroup() *ItemUpdate {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Item entity.
|
|
func (_u *ItemUpdate) ClearParent() *ItemUpdate {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Item entity.
|
|
func (_u *ItemUpdate) ClearChildren() *ItemUpdate {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Item entities by IDs.
|
|
func (_u *ItemUpdate) RemoveChildIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Item entities.
|
|
func (_u *ItemUpdate) RemoveChildren(v ...*Item) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (_u *ItemUpdate) ClearLabel() *ItemUpdate {
|
|
_u.mutation.ClearLabel()
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (_u *ItemUpdate) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.RemoveLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (_u *ItemUpdate) RemoveLabel(v ...*Label) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Location entity.
|
|
func (_u *ItemUpdate) ClearLocation() *ItemUpdate {
|
|
_u.mutation.ClearLocation()
|
|
return _u
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the ItemField entity.
|
|
func (_u *ItemUpdate) ClearFields() *ItemUpdate {
|
|
_u.mutation.ClearFields()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to ItemField entities by IDs.
|
|
func (_u *ItemUpdate) RemoveFieldIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.RemoveFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to ItemField entities.
|
|
func (_u *ItemUpdate) RemoveFields(v ...*ItemField) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *ItemUpdate) ClearMaintenanceEntries() *ItemUpdate {
|
|
_u.mutation.ClearMaintenanceEntries()
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (_u *ItemUpdate) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (_u *ItemUpdate) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (_u *ItemUpdate) ClearAttachments() *ItemUpdate {
|
|
_u.mutation.ClearAttachments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (_u *ItemUpdate) RemoveAttachmentIDs(ids ...uuid.UUID) *ItemUpdate {
|
|
_u.mutation.RemoveAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (_u *ItemUpdate) RemoveAttachments(v ...*Attachment) *ItemUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *ItemUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ItemUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ItemUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ItemUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ItemUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := item.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ItemUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := item.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Item.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Description(); ok {
|
|
if err := item.DescriptionValidator(v); err != nil {
|
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Item.description": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ImportRef(); ok {
|
|
if err := item.ImportRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Item.import_ref": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Notes(); ok {
|
|
if err := item.NotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Item.notes": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SerialNumber(); ok {
|
|
if err := item.SerialNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Item.serial_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ModelNumber(); ok {
|
|
if err := item.ModelNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Item.model_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Manufacturer(); ok {
|
|
if err := item.ManufacturerValidator(v); err != nil {
|
|
return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Item.manufacturer": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.WarrantyDetails(); ok {
|
|
if err := item.WarrantyDetailsValidator(v); err != nil {
|
|
return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Item.warranty_details": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SoldNotes(); ok {
|
|
if err := item.SoldNotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Item.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *ItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(item.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(item.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(item.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(item.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ImportRef(); ok {
|
|
_spec.SetField(item.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ImportRefCleared() {
|
|
_spec.ClearField(item.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Notes(); ok {
|
|
_spec.SetField(item.FieldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NotesCleared() {
|
|
_spec.ClearField(item.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(item.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(item.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Insured(); ok {
|
|
_spec.SetField(item.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Archived(); ok {
|
|
_spec.SetField(item.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.AssetID(); ok {
|
|
_spec.SetField(item.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(item.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SyncChildItemsLocations(); ok {
|
|
_spec.SetField(item.FieldSyncChildItemsLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.SerialNumber(); ok {
|
|
_spec.SetField(item.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(item.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ModelNumber(); ok {
|
|
_spec.SetField(item.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(item.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Manufacturer(); ok {
|
|
_spec.SetField(item.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(item.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(item.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(item.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if _u.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(item.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(item.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(item.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(item.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(item.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldTime(); ok {
|
|
_spec.SetField(item.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(item.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SoldTo(); ok {
|
|
_spec.SetField(item.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldToCleared() {
|
|
_spec.ClearField(item.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.SoldPrice(); ok {
|
|
_spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldNotes(); ok {
|
|
_spec.SetField(item.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.GroupTable,
|
|
Columns: []string{item.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.GroupTable,
|
|
Columns: []string{item.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.ParentTable,
|
|
Columns: []string{item.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.ParentTable,
|
|
Columns: []string{item.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.LocationTable,
|
|
Columns: []string{item.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.LocationTable,
|
|
Columns: []string{item.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AttachmentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{item.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ItemUpdateOne is the builder for updating a single Item entity.
|
|
type ItemUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ItemMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *ItemUpdateOne) SetUpdatedAt(v time.Time) *ItemUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *ItemUpdateOne) SetName(v string) *ItemUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableName(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *ItemUpdateOne) SetDescription(v string) *ItemUpdateOne {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableDescription(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *ItemUpdateOne) ClearDescription() *ItemUpdateOne {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (_u *ItemUpdateOne) SetImportRef(v string) *ItemUpdateOne {
|
|
_u.mutation.SetImportRef(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableImportRef(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetImportRef(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (_u *ItemUpdateOne) ClearImportRef() *ItemUpdateOne {
|
|
_u.mutation.ClearImportRef()
|
|
return _u
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (_u *ItemUpdateOne) SetNotes(v string) *ItemUpdateOne {
|
|
_u.mutation.SetNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableNotes(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (_u *ItemUpdateOne) ClearNotes() *ItemUpdateOne {
|
|
_u.mutation.ClearNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *ItemUpdateOne) SetQuantity(v int) *ItemUpdateOne {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableQuantity(v *int) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *ItemUpdateOne) AddQuantity(v int) *ItemUpdateOne {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (_u *ItemUpdateOne) SetInsured(v bool) *ItemUpdateOne {
|
|
_u.mutation.SetInsured(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableInsured(v *bool) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetInsured(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (_u *ItemUpdateOne) SetArchived(v bool) *ItemUpdateOne {
|
|
_u.mutation.SetArchived(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableArchived(v *bool) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetArchived(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (_u *ItemUpdateOne) SetAssetID(v int) *ItemUpdateOne {
|
|
_u.mutation.ResetAssetID()
|
|
_u.mutation.SetAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableAssetID(v *int) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetAssetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAssetID adds value to the "asset_id" field.
|
|
func (_u *ItemUpdateOne) AddAssetID(v int) *ItemUpdateOne {
|
|
_u.mutation.AddAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSyncChildItemsLocations sets the "sync_child_items_locations" field.
|
|
func (_u *ItemUpdateOne) SetSyncChildItemsLocations(v bool) *ItemUpdateOne {
|
|
_u.mutation.SetSyncChildItemsLocations(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSyncChildItemsLocations sets the "sync_child_items_locations" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSyncChildItemsLocations(v *bool) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSyncChildItemsLocations(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (_u *ItemUpdateOne) SetSerialNumber(v string) *ItemUpdateOne {
|
|
_u.mutation.SetSerialNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSerialNumber(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSerialNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (_u *ItemUpdateOne) ClearSerialNumber() *ItemUpdateOne {
|
|
_u.mutation.ClearSerialNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (_u *ItemUpdateOne) SetModelNumber(v string) *ItemUpdateOne {
|
|
_u.mutation.SetModelNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableModelNumber(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetModelNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (_u *ItemUpdateOne) ClearModelNumber() *ItemUpdateOne {
|
|
_u.mutation.ClearModelNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (_u *ItemUpdateOne) SetManufacturer(v string) *ItemUpdateOne {
|
|
_u.mutation.SetManufacturer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableManufacturer(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetManufacturer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (_u *ItemUpdateOne) ClearManufacturer() *ItemUpdateOne {
|
|
_u.mutation.ClearManufacturer()
|
|
return _u
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (_u *ItemUpdateOne) SetLifetimeWarranty(v bool) *ItemUpdateOne {
|
|
_u.mutation.SetLifetimeWarranty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableLifetimeWarranty(v *bool) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetLifetimeWarranty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (_u *ItemUpdateOne) SetWarrantyExpires(v time.Time) *ItemUpdateOne {
|
|
_u.mutation.SetWarrantyExpires(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableWarrantyExpires(v *time.Time) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetWarrantyExpires(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (_u *ItemUpdateOne) ClearWarrantyExpires() *ItemUpdateOne {
|
|
_u.mutation.ClearWarrantyExpires()
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (_u *ItemUpdateOne) SetWarrantyDetails(v string) *ItemUpdateOne {
|
|
_u.mutation.SetWarrantyDetails(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableWarrantyDetails(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetWarrantyDetails(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (_u *ItemUpdateOne) ClearWarrantyDetails() *ItemUpdateOne {
|
|
_u.mutation.ClearWarrantyDetails()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (_u *ItemUpdateOne) SetPurchaseTime(v time.Time) *ItemUpdateOne {
|
|
_u.mutation.SetPurchaseTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillablePurchaseTime(v *time.Time) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchaseTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (_u *ItemUpdateOne) ClearPurchaseTime() *ItemUpdateOne {
|
|
_u.mutation.ClearPurchaseTime()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (_u *ItemUpdateOne) SetPurchaseFrom(v string) *ItemUpdateOne {
|
|
_u.mutation.SetPurchaseFrom(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillablePurchaseFrom(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchaseFrom(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (_u *ItemUpdateOne) ClearPurchaseFrom() *ItemUpdateOne {
|
|
_u.mutation.ClearPurchaseFrom()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (_u *ItemUpdateOne) SetPurchasePrice(v float64) *ItemUpdateOne {
|
|
_u.mutation.ResetPurchasePrice()
|
|
_u.mutation.SetPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillablePurchasePrice(v *float64) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchasePrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPurchasePrice adds value to the "purchase_price" field.
|
|
func (_u *ItemUpdateOne) AddPurchasePrice(v float64) *ItemUpdateOne {
|
|
_u.mutation.AddPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (_u *ItemUpdateOne) SetSoldTime(v time.Time) *ItemUpdateOne {
|
|
_u.mutation.SetSoldTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSoldTime(v *time.Time) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (_u *ItemUpdateOne) ClearSoldTime() *ItemUpdateOne {
|
|
_u.mutation.ClearSoldTime()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (_u *ItemUpdateOne) SetSoldTo(v string) *ItemUpdateOne {
|
|
_u.mutation.SetSoldTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSoldTo(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (_u *ItemUpdateOne) ClearSoldTo() *ItemUpdateOne {
|
|
_u.mutation.ClearSoldTo()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (_u *ItemUpdateOne) SetSoldPrice(v float64) *ItemUpdateOne {
|
|
_u.mutation.ResetSoldPrice()
|
|
_u.mutation.SetSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSoldPrice(v *float64) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldPrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSoldPrice adds value to the "sold_price" field.
|
|
func (_u *ItemUpdateOne) AddSoldPrice(v float64) *ItemUpdateOne {
|
|
_u.mutation.AddSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (_u *ItemUpdateOne) SetSoldNotes(v string) *ItemUpdateOne {
|
|
_u.mutation.SetSoldNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableSoldNotes(v *string) *ItemUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (_u *ItemUpdateOne) ClearSoldNotes() *ItemUpdateOne {
|
|
_u.mutation.ClearSoldNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *ItemUpdateOne) SetGroupID(id uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *ItemUpdateOne) SetGroup(v *Group) *ItemUpdateOne {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Item entity by ID.
|
|
func (_u *ItemUpdateOne) SetParentID(id uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Item entity by ID if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableParentID(id *uuid.UUID) *ItemUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Item entity.
|
|
func (_u *ItemUpdateOne) SetParent(v *Item) *ItemUpdateOne {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Item entity by IDs.
|
|
func (_u *ItemUpdateOne) AddChildIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Item entity.
|
|
func (_u *ItemUpdateOne) AddChildren(v ...*Item) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (_u *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.AddLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (_u *ItemUpdateOne) AddLabel(v ...*Label) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Location entity by ID.
|
|
func (_u *ItemUpdateOne) SetLocationID(id uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.SetLocationID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
|
|
func (_u *ItemUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetLocationID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Location entity.
|
|
func (_u *ItemUpdateOne) SetLocation(v *Location) *ItemUpdateOne {
|
|
return _u.SetLocationID(v.ID)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the ItemField entity by IDs.
|
|
func (_u *ItemUpdateOne) AddFieldIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.AddFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the ItemField entity.
|
|
func (_u *ItemUpdateOne) AddFields(v ...*ItemField) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (_u *ItemUpdateOne) AddMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *ItemUpdateOne) AddMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (_u *ItemUpdateOne) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.AddAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (_u *ItemUpdateOne) AddAttachments(v ...*Attachment) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ItemMutation object of the builder.
|
|
func (_u *ItemUpdateOne) Mutation() *ItemMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *ItemUpdateOne) ClearGroup() *ItemUpdateOne {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Item entity.
|
|
func (_u *ItemUpdateOne) ClearParent() *ItemUpdateOne {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Item entity.
|
|
func (_u *ItemUpdateOne) ClearChildren() *ItemUpdateOne {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Item entities by IDs.
|
|
func (_u *ItemUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Item entities.
|
|
func (_u *ItemUpdateOne) RemoveChildren(v ...*Item) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (_u *ItemUpdateOne) ClearLabel() *ItemUpdateOne {
|
|
_u.mutation.ClearLabel()
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (_u *ItemUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.RemoveLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (_u *ItemUpdateOne) RemoveLabel(v ...*Label) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Location entity.
|
|
func (_u *ItemUpdateOne) ClearLocation() *ItemUpdateOne {
|
|
_u.mutation.ClearLocation()
|
|
return _u
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the ItemField entity.
|
|
func (_u *ItemUpdateOne) ClearFields() *ItemUpdateOne {
|
|
_u.mutation.ClearFields()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to ItemField entities by IDs.
|
|
func (_u *ItemUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.RemoveFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to ItemField entities.
|
|
func (_u *ItemUpdateOne) RemoveFields(v ...*ItemField) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *ItemUpdateOne) ClearMaintenanceEntries() *ItemUpdateOne {
|
|
_u.mutation.ClearMaintenanceEntries()
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (_u *ItemUpdateOne) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (_u *ItemUpdateOne) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (_u *ItemUpdateOne) ClearAttachments() *ItemUpdateOne {
|
|
_u.mutation.ClearAttachments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (_u *ItemUpdateOne) RemoveAttachmentIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
|
_u.mutation.RemoveAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (_u *ItemUpdateOne) RemoveAttachments(v ...*Attachment) *ItemUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the ItemUpdate builder.
|
|
func (_u *ItemUpdateOne) Where(ps ...predicate.Item) *ItemUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Item entity.
|
|
func (_u *ItemUpdateOne) Save(ctx context.Context) (*Item, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ItemUpdateOne) SaveX(ctx context.Context) *Item {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ItemUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ItemUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *ItemUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := item.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ItemUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := item.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Item.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Description(); ok {
|
|
if err := item.DescriptionValidator(v); err != nil {
|
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Item.description": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ImportRef(); ok {
|
|
if err := item.ImportRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Item.import_ref": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Notes(); ok {
|
|
if err := item.NotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Item.notes": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SerialNumber(); ok {
|
|
if err := item.SerialNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Item.serial_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ModelNumber(); ok {
|
|
if err := item.ModelNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Item.model_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Manufacturer(); ok {
|
|
if err := item.ManufacturerValidator(v); err != nil {
|
|
return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Item.manufacturer": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.WarrantyDetails(); ok {
|
|
if err := item.WarrantyDetailsValidator(v); err != nil {
|
|
return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Item.warranty_details": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.SoldNotes(); ok {
|
|
if err := item.SoldNotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Item.sold_notes": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Item.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(item.Table, item.Columns, sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Item.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, item.FieldID)
|
|
for _, f := range fields {
|
|
if !item.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != item.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(item.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(item.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(item.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(item.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ImportRef(); ok {
|
|
_spec.SetField(item.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ImportRefCleared() {
|
|
_spec.ClearField(item.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Notes(); ok {
|
|
_spec.SetField(item.FieldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NotesCleared() {
|
|
_spec.ClearField(item.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(item.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(item.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Insured(); ok {
|
|
_spec.SetField(item.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Archived(); ok {
|
|
_spec.SetField(item.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.AssetID(); ok {
|
|
_spec.SetField(item.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(item.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SyncChildItemsLocations(); ok {
|
|
_spec.SetField(item.FieldSyncChildItemsLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.SerialNumber(); ok {
|
|
_spec.SetField(item.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(item.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ModelNumber(); ok {
|
|
_spec.SetField(item.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(item.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Manufacturer(); ok {
|
|
_spec.SetField(item.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(item.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(item.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(item.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(item.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(item.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if _u.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(item.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(item.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(item.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(item.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(item.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(item.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldTime(); ok {
|
|
_spec.SetField(item.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(item.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SoldTo(); ok {
|
|
_spec.SetField(item.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldToCleared() {
|
|
_spec.ClearField(item.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.SoldPrice(); ok {
|
|
_spec.SetField(item.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(item.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldNotes(); ok {
|
|
_spec.SetField(item.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(item.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.GroupTable,
|
|
Columns: []string{item.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.GroupTable,
|
|
Columns: []string{item.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.ParentTable,
|
|
Columns: []string{item.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.ParentTable,
|
|
Columns: []string{item.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.ChildrenTable,
|
|
Columns: []string{item.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: item.LabelTable,
|
|
Columns: item.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.LocationTable,
|
|
Columns: []string{item.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: item.LocationTable,
|
|
Columns: []string{item.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.FieldsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.FieldsTable,
|
|
Columns: []string{item.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(itemfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.MaintenanceEntriesTable,
|
|
Columns: []string{item.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AttachmentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: item.AttachmentsTable,
|
|
Columns: []string{item.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Item{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{item.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|