vet/ent/reportdependency_update.go
Abhisek Datta 5f4cccbc85
feat: Add Support for Agentic Query and Analysis (#535)
* Add initial UI for agent mode

* fix: Cleanup and define agent contract

* Add react agent

* Add interactions memory

* Add support for stdio based MCP integration

* Add basic sqlite3 report generator

* fix: Persist vulnerabilities with package relation

* fix: Persist license information

* refactor: Agents into its own command package

* feat: Add support for tool calling introspection

* refactor: UI to hide implementation detail

* sqlite3 reporter persist dependency graph

* fix: Support multiple LLM provider for agent

* docs: Update agents doc

* docs: Remove deprecated query docs

* fix: UI tests

* fix: Linter issue

* Add support for prompt mode

* Improve UI with animation

* Fix UI tests after update

* Add OpenSSF scorecard persistence

* Add slsa provenances in sqlite3 reporter

* Add test cases for sqlite3 reporter

* Fix agent doc

* fix: Sqlite3 reporter use safe accessors

* feat: Add support for fast model

* feat: Simplify and streamline agent UI for better user experience

- Remove decorative borders and excessive styling to maximize output area
- Implement clean minimal design similar to modern TUI interfaces
- Add bordered input area for clear visual separation
- Move thinking indicator above input area for better visibility
- Enhance input field reset logic for proper line alignment
- Remove verbose help text and status messages
- Optimize layout calculations for full width utilization
- Add smooth animations for agent thinking state with spinner
- Clean up code structure and remove unused progress bar functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Improve agent status line

* test: Update UI tests

* fix: Use terminal safe rendering

* fix: Fix nil deref without storing empty strings in DB

* fix: Support overwriting sqlite3 database

* fix: Data model to use m2m between manifest and package

* style: Fix linter issue with unused variables

* Misc fixes

* Add test for agent memory

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-11 18:37:44 +05:30

688 lines
23 KiB
Go

// 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/safedep/vet/ent/predicate"
"github.com/safedep/vet/ent/reportdependency"
"github.com/safedep/vet/ent/reportpackage"
)
// ReportDependencyUpdate is the builder for updating ReportDependency entities.
type ReportDependencyUpdate struct {
config
hooks []Hook
mutation *ReportDependencyMutation
}
// Where appends a list predicates to the ReportDependencyUpdate builder.
func (rdu *ReportDependencyUpdate) Where(ps ...predicate.ReportDependency) *ReportDependencyUpdate {
rdu.mutation.Where(ps...)
return rdu
}
// SetDependencyPackageID sets the "dependency_package_id" field.
func (rdu *ReportDependencyUpdate) SetDependencyPackageID(s string) *ReportDependencyUpdate {
rdu.mutation.SetDependencyPackageID(s)
return rdu
}
// SetNillableDependencyPackageID sets the "dependency_package_id" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDependencyPackageID(s *string) *ReportDependencyUpdate {
if s != nil {
rdu.SetDependencyPackageID(*s)
}
return rdu
}
// SetDependencyName sets the "dependency_name" field.
func (rdu *ReportDependencyUpdate) SetDependencyName(s string) *ReportDependencyUpdate {
rdu.mutation.SetDependencyName(s)
return rdu
}
// SetNillableDependencyName sets the "dependency_name" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDependencyName(s *string) *ReportDependencyUpdate {
if s != nil {
rdu.SetDependencyName(*s)
}
return rdu
}
// SetDependencyVersion sets the "dependency_version" field.
func (rdu *ReportDependencyUpdate) SetDependencyVersion(s string) *ReportDependencyUpdate {
rdu.mutation.SetDependencyVersion(s)
return rdu
}
// SetNillableDependencyVersion sets the "dependency_version" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDependencyVersion(s *string) *ReportDependencyUpdate {
if s != nil {
rdu.SetDependencyVersion(*s)
}
return rdu
}
// SetDependencyEcosystem sets the "dependency_ecosystem" field.
func (rdu *ReportDependencyUpdate) SetDependencyEcosystem(s string) *ReportDependencyUpdate {
rdu.mutation.SetDependencyEcosystem(s)
return rdu
}
// SetNillableDependencyEcosystem sets the "dependency_ecosystem" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDependencyEcosystem(s *string) *ReportDependencyUpdate {
if s != nil {
rdu.SetDependencyEcosystem(*s)
}
return rdu
}
// SetDependencyType sets the "dependency_type" field.
func (rdu *ReportDependencyUpdate) SetDependencyType(s string) *ReportDependencyUpdate {
rdu.mutation.SetDependencyType(s)
return rdu
}
// SetNillableDependencyType sets the "dependency_type" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDependencyType(s *string) *ReportDependencyUpdate {
if s != nil {
rdu.SetDependencyType(*s)
}
return rdu
}
// ClearDependencyType clears the value of the "dependency_type" field.
func (rdu *ReportDependencyUpdate) ClearDependencyType() *ReportDependencyUpdate {
rdu.mutation.ClearDependencyType()
return rdu
}
// SetDepth sets the "depth" field.
func (rdu *ReportDependencyUpdate) SetDepth(i int) *ReportDependencyUpdate {
rdu.mutation.ResetDepth()
rdu.mutation.SetDepth(i)
return rdu
}
// SetNillableDepth sets the "depth" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableDepth(i *int) *ReportDependencyUpdate {
if i != nil {
rdu.SetDepth(*i)
}
return rdu
}
// AddDepth adds i to the "depth" field.
func (rdu *ReportDependencyUpdate) AddDepth(i int) *ReportDependencyUpdate {
rdu.mutation.AddDepth(i)
return rdu
}
// SetCreatedAt sets the "created_at" field.
func (rdu *ReportDependencyUpdate) SetCreatedAt(t time.Time) *ReportDependencyUpdate {
rdu.mutation.SetCreatedAt(t)
return rdu
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableCreatedAt(t *time.Time) *ReportDependencyUpdate {
if t != nil {
rdu.SetCreatedAt(*t)
}
return rdu
}
// ClearCreatedAt clears the value of the "created_at" field.
func (rdu *ReportDependencyUpdate) ClearCreatedAt() *ReportDependencyUpdate {
rdu.mutation.ClearCreatedAt()
return rdu
}
// SetUpdatedAt sets the "updated_at" field.
func (rdu *ReportDependencyUpdate) SetUpdatedAt(t time.Time) *ReportDependencyUpdate {
rdu.mutation.SetUpdatedAt(t)
return rdu
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillableUpdatedAt(t *time.Time) *ReportDependencyUpdate {
if t != nil {
rdu.SetUpdatedAt(*t)
}
return rdu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (rdu *ReportDependencyUpdate) ClearUpdatedAt() *ReportDependencyUpdate {
rdu.mutation.ClearUpdatedAt()
return rdu
}
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
func (rdu *ReportDependencyUpdate) SetPackageID(id int) *ReportDependencyUpdate {
rdu.mutation.SetPackageID(id)
return rdu
}
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
func (rdu *ReportDependencyUpdate) SetNillablePackageID(id *int) *ReportDependencyUpdate {
if id != nil {
rdu = rdu.SetPackageID(*id)
}
return rdu
}
// SetPackage sets the "package" edge to the ReportPackage entity.
func (rdu *ReportDependencyUpdate) SetPackage(r *ReportPackage) *ReportDependencyUpdate {
return rdu.SetPackageID(r.ID)
}
// Mutation returns the ReportDependencyMutation object of the builder.
func (rdu *ReportDependencyUpdate) Mutation() *ReportDependencyMutation {
return rdu.mutation
}
// ClearPackage clears the "package" edge to the ReportPackage entity.
func (rdu *ReportDependencyUpdate) ClearPackage() *ReportDependencyUpdate {
rdu.mutation.ClearPackage()
return rdu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (rdu *ReportDependencyUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, rdu.sqlSave, rdu.mutation, rdu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (rdu *ReportDependencyUpdate) SaveX(ctx context.Context) int {
affected, err := rdu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (rdu *ReportDependencyUpdate) Exec(ctx context.Context) error {
_, err := rdu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rdu *ReportDependencyUpdate) ExecX(ctx context.Context) {
if err := rdu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (rdu *ReportDependencyUpdate) check() error {
if v, ok := rdu.mutation.DependencyPackageID(); ok {
if err := reportdependency.DependencyPackageIDValidator(v); err != nil {
return &ValidationError{Name: "dependency_package_id", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_package_id": %w`, err)}
}
}
if v, ok := rdu.mutation.DependencyName(); ok {
if err := reportdependency.DependencyNameValidator(v); err != nil {
return &ValidationError{Name: "dependency_name", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_name": %w`, err)}
}
}
if v, ok := rdu.mutation.DependencyVersion(); ok {
if err := reportdependency.DependencyVersionValidator(v); err != nil {
return &ValidationError{Name: "dependency_version", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_version": %w`, err)}
}
}
if v, ok := rdu.mutation.DependencyEcosystem(); ok {
if err := reportdependency.DependencyEcosystemValidator(v); err != nil {
return &ValidationError{Name: "dependency_ecosystem", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_ecosystem": %w`, err)}
}
}
return nil
}
func (rdu *ReportDependencyUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := rdu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(reportdependency.Table, reportdependency.Columns, sqlgraph.NewFieldSpec(reportdependency.FieldID, field.TypeInt))
if ps := rdu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := rdu.mutation.DependencyPackageID(); ok {
_spec.SetField(reportdependency.FieldDependencyPackageID, field.TypeString, value)
}
if value, ok := rdu.mutation.DependencyName(); ok {
_spec.SetField(reportdependency.FieldDependencyName, field.TypeString, value)
}
if value, ok := rdu.mutation.DependencyVersion(); ok {
_spec.SetField(reportdependency.FieldDependencyVersion, field.TypeString, value)
}
if value, ok := rdu.mutation.DependencyEcosystem(); ok {
_spec.SetField(reportdependency.FieldDependencyEcosystem, field.TypeString, value)
}
if value, ok := rdu.mutation.DependencyType(); ok {
_spec.SetField(reportdependency.FieldDependencyType, field.TypeString, value)
}
if rdu.mutation.DependencyTypeCleared() {
_spec.ClearField(reportdependency.FieldDependencyType, field.TypeString)
}
if value, ok := rdu.mutation.Depth(); ok {
_spec.SetField(reportdependency.FieldDepth, field.TypeInt, value)
}
if value, ok := rdu.mutation.AddedDepth(); ok {
_spec.AddField(reportdependency.FieldDepth, field.TypeInt, value)
}
if value, ok := rdu.mutation.CreatedAt(); ok {
_spec.SetField(reportdependency.FieldCreatedAt, field.TypeTime, value)
}
if rdu.mutation.CreatedAtCleared() {
_spec.ClearField(reportdependency.FieldCreatedAt, field.TypeTime)
}
if value, ok := rdu.mutation.UpdatedAt(); ok {
_spec.SetField(reportdependency.FieldUpdatedAt, field.TypeTime, value)
}
if rdu.mutation.UpdatedAtCleared() {
_spec.ClearField(reportdependency.FieldUpdatedAt, field.TypeTime)
}
if rdu.mutation.PackageCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportdependency.PackageTable,
Columns: []string{reportdependency.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := rdu.mutation.PackageIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportdependency.PackageTable,
Columns: []string{reportdependency.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, rdu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{reportdependency.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
rdu.mutation.done = true
return n, nil
}
// ReportDependencyUpdateOne is the builder for updating a single ReportDependency entity.
type ReportDependencyUpdateOne struct {
config
fields []string
hooks []Hook
mutation *ReportDependencyMutation
}
// SetDependencyPackageID sets the "dependency_package_id" field.
func (rduo *ReportDependencyUpdateOne) SetDependencyPackageID(s string) *ReportDependencyUpdateOne {
rduo.mutation.SetDependencyPackageID(s)
return rduo
}
// SetNillableDependencyPackageID sets the "dependency_package_id" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDependencyPackageID(s *string) *ReportDependencyUpdateOne {
if s != nil {
rduo.SetDependencyPackageID(*s)
}
return rduo
}
// SetDependencyName sets the "dependency_name" field.
func (rduo *ReportDependencyUpdateOne) SetDependencyName(s string) *ReportDependencyUpdateOne {
rduo.mutation.SetDependencyName(s)
return rduo
}
// SetNillableDependencyName sets the "dependency_name" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDependencyName(s *string) *ReportDependencyUpdateOne {
if s != nil {
rduo.SetDependencyName(*s)
}
return rduo
}
// SetDependencyVersion sets the "dependency_version" field.
func (rduo *ReportDependencyUpdateOne) SetDependencyVersion(s string) *ReportDependencyUpdateOne {
rduo.mutation.SetDependencyVersion(s)
return rduo
}
// SetNillableDependencyVersion sets the "dependency_version" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDependencyVersion(s *string) *ReportDependencyUpdateOne {
if s != nil {
rduo.SetDependencyVersion(*s)
}
return rduo
}
// SetDependencyEcosystem sets the "dependency_ecosystem" field.
func (rduo *ReportDependencyUpdateOne) SetDependencyEcosystem(s string) *ReportDependencyUpdateOne {
rduo.mutation.SetDependencyEcosystem(s)
return rduo
}
// SetNillableDependencyEcosystem sets the "dependency_ecosystem" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDependencyEcosystem(s *string) *ReportDependencyUpdateOne {
if s != nil {
rduo.SetDependencyEcosystem(*s)
}
return rduo
}
// SetDependencyType sets the "dependency_type" field.
func (rduo *ReportDependencyUpdateOne) SetDependencyType(s string) *ReportDependencyUpdateOne {
rduo.mutation.SetDependencyType(s)
return rduo
}
// SetNillableDependencyType sets the "dependency_type" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDependencyType(s *string) *ReportDependencyUpdateOne {
if s != nil {
rduo.SetDependencyType(*s)
}
return rduo
}
// ClearDependencyType clears the value of the "dependency_type" field.
func (rduo *ReportDependencyUpdateOne) ClearDependencyType() *ReportDependencyUpdateOne {
rduo.mutation.ClearDependencyType()
return rduo
}
// SetDepth sets the "depth" field.
func (rduo *ReportDependencyUpdateOne) SetDepth(i int) *ReportDependencyUpdateOne {
rduo.mutation.ResetDepth()
rduo.mutation.SetDepth(i)
return rduo
}
// SetNillableDepth sets the "depth" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableDepth(i *int) *ReportDependencyUpdateOne {
if i != nil {
rduo.SetDepth(*i)
}
return rduo
}
// AddDepth adds i to the "depth" field.
func (rduo *ReportDependencyUpdateOne) AddDepth(i int) *ReportDependencyUpdateOne {
rduo.mutation.AddDepth(i)
return rduo
}
// SetCreatedAt sets the "created_at" field.
func (rduo *ReportDependencyUpdateOne) SetCreatedAt(t time.Time) *ReportDependencyUpdateOne {
rduo.mutation.SetCreatedAt(t)
return rduo
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableCreatedAt(t *time.Time) *ReportDependencyUpdateOne {
if t != nil {
rduo.SetCreatedAt(*t)
}
return rduo
}
// ClearCreatedAt clears the value of the "created_at" field.
func (rduo *ReportDependencyUpdateOne) ClearCreatedAt() *ReportDependencyUpdateOne {
rduo.mutation.ClearCreatedAt()
return rduo
}
// SetUpdatedAt sets the "updated_at" field.
func (rduo *ReportDependencyUpdateOne) SetUpdatedAt(t time.Time) *ReportDependencyUpdateOne {
rduo.mutation.SetUpdatedAt(t)
return rduo
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillableUpdatedAt(t *time.Time) *ReportDependencyUpdateOne {
if t != nil {
rduo.SetUpdatedAt(*t)
}
return rduo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (rduo *ReportDependencyUpdateOne) ClearUpdatedAt() *ReportDependencyUpdateOne {
rduo.mutation.ClearUpdatedAt()
return rduo
}
// SetPackageID sets the "package" edge to the ReportPackage entity by ID.
func (rduo *ReportDependencyUpdateOne) SetPackageID(id int) *ReportDependencyUpdateOne {
rduo.mutation.SetPackageID(id)
return rduo
}
// SetNillablePackageID sets the "package" edge to the ReportPackage entity by ID if the given value is not nil.
func (rduo *ReportDependencyUpdateOne) SetNillablePackageID(id *int) *ReportDependencyUpdateOne {
if id != nil {
rduo = rduo.SetPackageID(*id)
}
return rduo
}
// SetPackage sets the "package" edge to the ReportPackage entity.
func (rduo *ReportDependencyUpdateOne) SetPackage(r *ReportPackage) *ReportDependencyUpdateOne {
return rduo.SetPackageID(r.ID)
}
// Mutation returns the ReportDependencyMutation object of the builder.
func (rduo *ReportDependencyUpdateOne) Mutation() *ReportDependencyMutation {
return rduo.mutation
}
// ClearPackage clears the "package" edge to the ReportPackage entity.
func (rduo *ReportDependencyUpdateOne) ClearPackage() *ReportDependencyUpdateOne {
rduo.mutation.ClearPackage()
return rduo
}
// Where appends a list predicates to the ReportDependencyUpdate builder.
func (rduo *ReportDependencyUpdateOne) Where(ps ...predicate.ReportDependency) *ReportDependencyUpdateOne {
rduo.mutation.Where(ps...)
return rduo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (rduo *ReportDependencyUpdateOne) Select(field string, fields ...string) *ReportDependencyUpdateOne {
rduo.fields = append([]string{field}, fields...)
return rduo
}
// Save executes the query and returns the updated ReportDependency entity.
func (rduo *ReportDependencyUpdateOne) Save(ctx context.Context) (*ReportDependency, error) {
return withHooks(ctx, rduo.sqlSave, rduo.mutation, rduo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (rduo *ReportDependencyUpdateOne) SaveX(ctx context.Context) *ReportDependency {
node, err := rduo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (rduo *ReportDependencyUpdateOne) Exec(ctx context.Context) error {
_, err := rduo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (rduo *ReportDependencyUpdateOne) ExecX(ctx context.Context) {
if err := rduo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (rduo *ReportDependencyUpdateOne) check() error {
if v, ok := rduo.mutation.DependencyPackageID(); ok {
if err := reportdependency.DependencyPackageIDValidator(v); err != nil {
return &ValidationError{Name: "dependency_package_id", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_package_id": %w`, err)}
}
}
if v, ok := rduo.mutation.DependencyName(); ok {
if err := reportdependency.DependencyNameValidator(v); err != nil {
return &ValidationError{Name: "dependency_name", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_name": %w`, err)}
}
}
if v, ok := rduo.mutation.DependencyVersion(); ok {
if err := reportdependency.DependencyVersionValidator(v); err != nil {
return &ValidationError{Name: "dependency_version", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_version": %w`, err)}
}
}
if v, ok := rduo.mutation.DependencyEcosystem(); ok {
if err := reportdependency.DependencyEcosystemValidator(v); err != nil {
return &ValidationError{Name: "dependency_ecosystem", err: fmt.Errorf(`ent: validator failed for field "ReportDependency.dependency_ecosystem": %w`, err)}
}
}
return nil
}
func (rduo *ReportDependencyUpdateOne) sqlSave(ctx context.Context) (_node *ReportDependency, err error) {
if err := rduo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(reportdependency.Table, reportdependency.Columns, sqlgraph.NewFieldSpec(reportdependency.FieldID, field.TypeInt))
id, ok := rduo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ReportDependency.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := rduo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, reportdependency.FieldID)
for _, f := range fields {
if !reportdependency.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != reportdependency.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := rduo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := rduo.mutation.DependencyPackageID(); ok {
_spec.SetField(reportdependency.FieldDependencyPackageID, field.TypeString, value)
}
if value, ok := rduo.mutation.DependencyName(); ok {
_spec.SetField(reportdependency.FieldDependencyName, field.TypeString, value)
}
if value, ok := rduo.mutation.DependencyVersion(); ok {
_spec.SetField(reportdependency.FieldDependencyVersion, field.TypeString, value)
}
if value, ok := rduo.mutation.DependencyEcosystem(); ok {
_spec.SetField(reportdependency.FieldDependencyEcosystem, field.TypeString, value)
}
if value, ok := rduo.mutation.DependencyType(); ok {
_spec.SetField(reportdependency.FieldDependencyType, field.TypeString, value)
}
if rduo.mutation.DependencyTypeCleared() {
_spec.ClearField(reportdependency.FieldDependencyType, field.TypeString)
}
if value, ok := rduo.mutation.Depth(); ok {
_spec.SetField(reportdependency.FieldDepth, field.TypeInt, value)
}
if value, ok := rduo.mutation.AddedDepth(); ok {
_spec.AddField(reportdependency.FieldDepth, field.TypeInt, value)
}
if value, ok := rduo.mutation.CreatedAt(); ok {
_spec.SetField(reportdependency.FieldCreatedAt, field.TypeTime, value)
}
if rduo.mutation.CreatedAtCleared() {
_spec.ClearField(reportdependency.FieldCreatedAt, field.TypeTime)
}
if value, ok := rduo.mutation.UpdatedAt(); ok {
_spec.SetField(reportdependency.FieldUpdatedAt, field.TypeTime, value)
}
if rduo.mutation.UpdatedAtCleared() {
_spec.ClearField(reportdependency.FieldUpdatedAt, field.TypeTime)
}
if rduo.mutation.PackageCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportdependency.PackageTable,
Columns: []string{reportdependency.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := rduo.mutation.PackageIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: reportdependency.PackageTable,
Columns: []string{reportdependency.PackageColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(reportpackage.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &ReportDependency{config: rduo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, rduo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{reportdependency.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
rduo.mutation.done = true
return _node, nil
}