mirror of
https://github.com/safedep/vet.git
synced 2025-12-11 01:01:10 -06:00
* 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>
528 lines
16 KiB
Go
528 lines
16 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"math"
|
|
|
|
"entgo.io/ent"
|
|
"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/reportdependencygraph"
|
|
)
|
|
|
|
// ReportDependencyGraphQuery is the builder for querying ReportDependencyGraph entities.
|
|
type ReportDependencyGraphQuery struct {
|
|
config
|
|
ctx *QueryContext
|
|
order []reportdependencygraph.OrderOption
|
|
inters []Interceptor
|
|
predicates []predicate.ReportDependencyGraph
|
|
// intermediate query (i.e. traversal path).
|
|
sql *sql.Selector
|
|
path func(context.Context) (*sql.Selector, error)
|
|
}
|
|
|
|
// Where adds a new predicate for the ReportDependencyGraphQuery builder.
|
|
func (rdgq *ReportDependencyGraphQuery) Where(ps ...predicate.ReportDependencyGraph) *ReportDependencyGraphQuery {
|
|
rdgq.predicates = append(rdgq.predicates, ps...)
|
|
return rdgq
|
|
}
|
|
|
|
// Limit the number of records to be returned by this query.
|
|
func (rdgq *ReportDependencyGraphQuery) Limit(limit int) *ReportDependencyGraphQuery {
|
|
rdgq.ctx.Limit = &limit
|
|
return rdgq
|
|
}
|
|
|
|
// Offset to start from.
|
|
func (rdgq *ReportDependencyGraphQuery) Offset(offset int) *ReportDependencyGraphQuery {
|
|
rdgq.ctx.Offset = &offset
|
|
return rdgq
|
|
}
|
|
|
|
// Unique configures the query builder to filter duplicate records on query.
|
|
// By default, unique is set to true, and can be disabled using this method.
|
|
func (rdgq *ReportDependencyGraphQuery) Unique(unique bool) *ReportDependencyGraphQuery {
|
|
rdgq.ctx.Unique = &unique
|
|
return rdgq
|
|
}
|
|
|
|
// Order specifies how the records should be ordered.
|
|
func (rdgq *ReportDependencyGraphQuery) Order(o ...reportdependencygraph.OrderOption) *ReportDependencyGraphQuery {
|
|
rdgq.order = append(rdgq.order, o...)
|
|
return rdgq
|
|
}
|
|
|
|
// First returns the first ReportDependencyGraph entity from the query.
|
|
// Returns a *NotFoundError when no ReportDependencyGraph was found.
|
|
func (rdgq *ReportDependencyGraphQuery) First(ctx context.Context) (*ReportDependencyGraph, error) {
|
|
nodes, err := rdgq.Limit(1).All(setContextOp(ctx, rdgq.ctx, ent.OpQueryFirst))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(nodes) == 0 {
|
|
return nil, &NotFoundError{reportdependencygraph.Label}
|
|
}
|
|
return nodes[0], nil
|
|
}
|
|
|
|
// FirstX is like First, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) FirstX(ctx context.Context) *ReportDependencyGraph {
|
|
node, err := rdgq.First(ctx)
|
|
if err != nil && !IsNotFound(err) {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// FirstID returns the first ReportDependencyGraph ID from the query.
|
|
// Returns a *NotFoundError when no ReportDependencyGraph ID was found.
|
|
func (rdgq *ReportDependencyGraphQuery) FirstID(ctx context.Context) (id int, err error) {
|
|
var ids []int
|
|
if ids, err = rdgq.Limit(1).IDs(setContextOp(ctx, rdgq.ctx, ent.OpQueryFirstID)); err != nil {
|
|
return
|
|
}
|
|
if len(ids) == 0 {
|
|
err = &NotFoundError{reportdependencygraph.Label}
|
|
return
|
|
}
|
|
return ids[0], nil
|
|
}
|
|
|
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) FirstIDX(ctx context.Context) int {
|
|
id, err := rdgq.FirstID(ctx)
|
|
if err != nil && !IsNotFound(err) {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// Only returns a single ReportDependencyGraph entity found by the query, ensuring it only returns one.
|
|
// Returns a *NotSingularError when more than one ReportDependencyGraph entity is found.
|
|
// Returns a *NotFoundError when no ReportDependencyGraph entities are found.
|
|
func (rdgq *ReportDependencyGraphQuery) Only(ctx context.Context) (*ReportDependencyGraph, error) {
|
|
nodes, err := rdgq.Limit(2).All(setContextOp(ctx, rdgq.ctx, ent.OpQueryOnly))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch len(nodes) {
|
|
case 1:
|
|
return nodes[0], nil
|
|
case 0:
|
|
return nil, &NotFoundError{reportdependencygraph.Label}
|
|
default:
|
|
return nil, &NotSingularError{reportdependencygraph.Label}
|
|
}
|
|
}
|
|
|
|
// OnlyX is like Only, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) OnlyX(ctx context.Context) *ReportDependencyGraph {
|
|
node, err := rdgq.Only(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// OnlyID is like Only, but returns the only ReportDependencyGraph ID in the query.
|
|
// Returns a *NotSingularError when more than one ReportDependencyGraph ID is found.
|
|
// Returns a *NotFoundError when no entities are found.
|
|
func (rdgq *ReportDependencyGraphQuery) OnlyID(ctx context.Context) (id int, err error) {
|
|
var ids []int
|
|
if ids, err = rdgq.Limit(2).IDs(setContextOp(ctx, rdgq.ctx, ent.OpQueryOnlyID)); err != nil {
|
|
return
|
|
}
|
|
switch len(ids) {
|
|
case 1:
|
|
id = ids[0]
|
|
case 0:
|
|
err = &NotFoundError{reportdependencygraph.Label}
|
|
default:
|
|
err = &NotSingularError{reportdependencygraph.Label}
|
|
}
|
|
return
|
|
}
|
|
|
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) OnlyIDX(ctx context.Context) int {
|
|
id, err := rdgq.OnlyID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// All executes the query and returns a list of ReportDependencyGraphs.
|
|
func (rdgq *ReportDependencyGraphQuery) All(ctx context.Context) ([]*ReportDependencyGraph, error) {
|
|
ctx = setContextOp(ctx, rdgq.ctx, ent.OpQueryAll)
|
|
if err := rdgq.prepareQuery(ctx); err != nil {
|
|
return nil, err
|
|
}
|
|
qr := querierAll[[]*ReportDependencyGraph, *ReportDependencyGraphQuery]()
|
|
return withInterceptors[[]*ReportDependencyGraph](ctx, rdgq, qr, rdgq.inters)
|
|
}
|
|
|
|
// AllX is like All, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) AllX(ctx context.Context) []*ReportDependencyGraph {
|
|
nodes, err := rdgq.All(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return nodes
|
|
}
|
|
|
|
// IDs executes the query and returns a list of ReportDependencyGraph IDs.
|
|
func (rdgq *ReportDependencyGraphQuery) IDs(ctx context.Context) (ids []int, err error) {
|
|
if rdgq.ctx.Unique == nil && rdgq.path != nil {
|
|
rdgq.Unique(true)
|
|
}
|
|
ctx = setContextOp(ctx, rdgq.ctx, ent.OpQueryIDs)
|
|
if err = rdgq.Select(reportdependencygraph.FieldID).Scan(ctx, &ids); err != nil {
|
|
return nil, err
|
|
}
|
|
return ids, nil
|
|
}
|
|
|
|
// IDsX is like IDs, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) IDsX(ctx context.Context) []int {
|
|
ids, err := rdgq.IDs(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return ids
|
|
}
|
|
|
|
// Count returns the count of the given query.
|
|
func (rdgq *ReportDependencyGraphQuery) Count(ctx context.Context) (int, error) {
|
|
ctx = setContextOp(ctx, rdgq.ctx, ent.OpQueryCount)
|
|
if err := rdgq.prepareQuery(ctx); err != nil {
|
|
return 0, err
|
|
}
|
|
return withInterceptors[int](ctx, rdgq, querierCount[*ReportDependencyGraphQuery](), rdgq.inters)
|
|
}
|
|
|
|
// CountX is like Count, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) CountX(ctx context.Context) int {
|
|
count, err := rdgq.Count(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return count
|
|
}
|
|
|
|
// Exist returns true if the query has elements in the graph.
|
|
func (rdgq *ReportDependencyGraphQuery) Exist(ctx context.Context) (bool, error) {
|
|
ctx = setContextOp(ctx, rdgq.ctx, ent.OpQueryExist)
|
|
switch _, err := rdgq.FirstID(ctx); {
|
|
case IsNotFound(err):
|
|
return false, nil
|
|
case err != nil:
|
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
|
default:
|
|
return true, nil
|
|
}
|
|
}
|
|
|
|
// ExistX is like Exist, but panics if an error occurs.
|
|
func (rdgq *ReportDependencyGraphQuery) ExistX(ctx context.Context) bool {
|
|
exist, err := rdgq.Exist(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return exist
|
|
}
|
|
|
|
// Clone returns a duplicate of the ReportDependencyGraphQuery builder, including all associated steps. It can be
|
|
// used to prepare common query builders and use them differently after the clone is made.
|
|
func (rdgq *ReportDependencyGraphQuery) Clone() *ReportDependencyGraphQuery {
|
|
if rdgq == nil {
|
|
return nil
|
|
}
|
|
return &ReportDependencyGraphQuery{
|
|
config: rdgq.config,
|
|
ctx: rdgq.ctx.Clone(),
|
|
order: append([]reportdependencygraph.OrderOption{}, rdgq.order...),
|
|
inters: append([]Interceptor{}, rdgq.inters...),
|
|
predicates: append([]predicate.ReportDependencyGraph{}, rdgq.predicates...),
|
|
// clone intermediate query.
|
|
sql: rdgq.sql.Clone(),
|
|
path: rdgq.path,
|
|
}
|
|
}
|
|
|
|
// GroupBy is used to group vertices by one or more fields/columns.
|
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
|
//
|
|
// Example:
|
|
//
|
|
// var v []struct {
|
|
// FromPackageID string `json:"from_package_id,omitempty"`
|
|
// Count int `json:"count,omitempty"`
|
|
// }
|
|
//
|
|
// client.ReportDependencyGraph.Query().
|
|
// GroupBy(reportdependencygraph.FieldFromPackageID).
|
|
// Aggregate(ent.Count()).
|
|
// Scan(ctx, &v)
|
|
func (rdgq *ReportDependencyGraphQuery) GroupBy(field string, fields ...string) *ReportDependencyGraphGroupBy {
|
|
rdgq.ctx.Fields = append([]string{field}, fields...)
|
|
grbuild := &ReportDependencyGraphGroupBy{build: rdgq}
|
|
grbuild.flds = &rdgq.ctx.Fields
|
|
grbuild.label = reportdependencygraph.Label
|
|
grbuild.scan = grbuild.Scan
|
|
return grbuild
|
|
}
|
|
|
|
// Select allows the selection one or more fields/columns for the given query,
|
|
// instead of selecting all fields in the entity.
|
|
//
|
|
// Example:
|
|
//
|
|
// var v []struct {
|
|
// FromPackageID string `json:"from_package_id,omitempty"`
|
|
// }
|
|
//
|
|
// client.ReportDependencyGraph.Query().
|
|
// Select(reportdependencygraph.FieldFromPackageID).
|
|
// Scan(ctx, &v)
|
|
func (rdgq *ReportDependencyGraphQuery) Select(fields ...string) *ReportDependencyGraphSelect {
|
|
rdgq.ctx.Fields = append(rdgq.ctx.Fields, fields...)
|
|
sbuild := &ReportDependencyGraphSelect{ReportDependencyGraphQuery: rdgq}
|
|
sbuild.label = reportdependencygraph.Label
|
|
sbuild.flds, sbuild.scan = &rdgq.ctx.Fields, sbuild.Scan
|
|
return sbuild
|
|
}
|
|
|
|
// Aggregate returns a ReportDependencyGraphSelect configured with the given aggregations.
|
|
func (rdgq *ReportDependencyGraphQuery) Aggregate(fns ...AggregateFunc) *ReportDependencyGraphSelect {
|
|
return rdgq.Select().Aggregate(fns...)
|
|
}
|
|
|
|
func (rdgq *ReportDependencyGraphQuery) prepareQuery(ctx context.Context) error {
|
|
for _, inter := range rdgq.inters {
|
|
if inter == nil {
|
|
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
|
}
|
|
if trv, ok := inter.(Traverser); ok {
|
|
if err := trv.Traverse(ctx, rdgq); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
for _, f := range rdgq.ctx.Fields {
|
|
if !reportdependencygraph.ValidColumn(f) {
|
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
}
|
|
if rdgq.path != nil {
|
|
prev, err := rdgq.path(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
rdgq.sql = prev
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (rdgq *ReportDependencyGraphQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ReportDependencyGraph, error) {
|
|
var (
|
|
nodes = []*ReportDependencyGraph{}
|
|
_spec = rdgq.querySpec()
|
|
)
|
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
|
return (*ReportDependencyGraph).scanValues(nil, columns)
|
|
}
|
|
_spec.Assign = func(columns []string, values []any) error {
|
|
node := &ReportDependencyGraph{config: rdgq.config}
|
|
nodes = append(nodes, node)
|
|
return node.assignValues(columns, values)
|
|
}
|
|
for i := range hooks {
|
|
hooks[i](ctx, _spec)
|
|
}
|
|
if err := sqlgraph.QueryNodes(ctx, rdgq.driver, _spec); err != nil {
|
|
return nil, err
|
|
}
|
|
if len(nodes) == 0 {
|
|
return nodes, nil
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
func (rdgq *ReportDependencyGraphQuery) sqlCount(ctx context.Context) (int, error) {
|
|
_spec := rdgq.querySpec()
|
|
_spec.Node.Columns = rdgq.ctx.Fields
|
|
if len(rdgq.ctx.Fields) > 0 {
|
|
_spec.Unique = rdgq.ctx.Unique != nil && *rdgq.ctx.Unique
|
|
}
|
|
return sqlgraph.CountNodes(ctx, rdgq.driver, _spec)
|
|
}
|
|
|
|
func (rdgq *ReportDependencyGraphQuery) querySpec() *sqlgraph.QuerySpec {
|
|
_spec := sqlgraph.NewQuerySpec(reportdependencygraph.Table, reportdependencygraph.Columns, sqlgraph.NewFieldSpec(reportdependencygraph.FieldID, field.TypeInt))
|
|
_spec.From = rdgq.sql
|
|
if unique := rdgq.ctx.Unique; unique != nil {
|
|
_spec.Unique = *unique
|
|
} else if rdgq.path != nil {
|
|
_spec.Unique = true
|
|
}
|
|
if fields := rdgq.ctx.Fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, reportdependencygraph.FieldID)
|
|
for i := range fields {
|
|
if fields[i] != reportdependencygraph.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
|
}
|
|
}
|
|
}
|
|
if ps := rdgq.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if limit := rdgq.ctx.Limit; limit != nil {
|
|
_spec.Limit = *limit
|
|
}
|
|
if offset := rdgq.ctx.Offset; offset != nil {
|
|
_spec.Offset = *offset
|
|
}
|
|
if ps := rdgq.order; len(ps) > 0 {
|
|
_spec.Order = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
return _spec
|
|
}
|
|
|
|
func (rdgq *ReportDependencyGraphQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
|
builder := sql.Dialect(rdgq.driver.Dialect())
|
|
t1 := builder.Table(reportdependencygraph.Table)
|
|
columns := rdgq.ctx.Fields
|
|
if len(columns) == 0 {
|
|
columns = reportdependencygraph.Columns
|
|
}
|
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
|
if rdgq.sql != nil {
|
|
selector = rdgq.sql
|
|
selector.Select(selector.Columns(columns...)...)
|
|
}
|
|
if rdgq.ctx.Unique != nil && *rdgq.ctx.Unique {
|
|
selector.Distinct()
|
|
}
|
|
for _, p := range rdgq.predicates {
|
|
p(selector)
|
|
}
|
|
for _, p := range rdgq.order {
|
|
p(selector)
|
|
}
|
|
if offset := rdgq.ctx.Offset; offset != nil {
|
|
// limit is mandatory for offset clause. We start
|
|
// with default value, and override it below if needed.
|
|
selector.Offset(*offset).Limit(math.MaxInt32)
|
|
}
|
|
if limit := rdgq.ctx.Limit; limit != nil {
|
|
selector.Limit(*limit)
|
|
}
|
|
return selector
|
|
}
|
|
|
|
// ReportDependencyGraphGroupBy is the group-by builder for ReportDependencyGraph entities.
|
|
type ReportDependencyGraphGroupBy struct {
|
|
selector
|
|
build *ReportDependencyGraphQuery
|
|
}
|
|
|
|
// Aggregate adds the given aggregation functions to the group-by query.
|
|
func (rdggb *ReportDependencyGraphGroupBy) Aggregate(fns ...AggregateFunc) *ReportDependencyGraphGroupBy {
|
|
rdggb.fns = append(rdggb.fns, fns...)
|
|
return rdggb
|
|
}
|
|
|
|
// Scan applies the selector query and scans the result into the given value.
|
|
func (rdggb *ReportDependencyGraphGroupBy) Scan(ctx context.Context, v any) error {
|
|
ctx = setContextOp(ctx, rdggb.build.ctx, ent.OpQueryGroupBy)
|
|
if err := rdggb.build.prepareQuery(ctx); err != nil {
|
|
return err
|
|
}
|
|
return scanWithInterceptors[*ReportDependencyGraphQuery, *ReportDependencyGraphGroupBy](ctx, rdggb.build, rdggb, rdggb.build.inters, v)
|
|
}
|
|
|
|
func (rdggb *ReportDependencyGraphGroupBy) sqlScan(ctx context.Context, root *ReportDependencyGraphQuery, v any) error {
|
|
selector := root.sqlQuery(ctx).Select()
|
|
aggregation := make([]string, 0, len(rdggb.fns))
|
|
for _, fn := range rdggb.fns {
|
|
aggregation = append(aggregation, fn(selector))
|
|
}
|
|
if len(selector.SelectedColumns()) == 0 {
|
|
columns := make([]string, 0, len(*rdggb.flds)+len(rdggb.fns))
|
|
for _, f := range *rdggb.flds {
|
|
columns = append(columns, selector.C(f))
|
|
}
|
|
columns = append(columns, aggregation...)
|
|
selector.Select(columns...)
|
|
}
|
|
selector.GroupBy(selector.Columns(*rdggb.flds...)...)
|
|
if err := selector.Err(); err != nil {
|
|
return err
|
|
}
|
|
rows := &sql.Rows{}
|
|
query, args := selector.Query()
|
|
if err := rdggb.build.driver.Query(ctx, query, args, rows); err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
return sql.ScanSlice(rows, v)
|
|
}
|
|
|
|
// ReportDependencyGraphSelect is the builder for selecting fields of ReportDependencyGraph entities.
|
|
type ReportDependencyGraphSelect struct {
|
|
*ReportDependencyGraphQuery
|
|
selector
|
|
}
|
|
|
|
// Aggregate adds the given aggregation functions to the selector query.
|
|
func (rdgs *ReportDependencyGraphSelect) Aggregate(fns ...AggregateFunc) *ReportDependencyGraphSelect {
|
|
rdgs.fns = append(rdgs.fns, fns...)
|
|
return rdgs
|
|
}
|
|
|
|
// Scan applies the selector query and scans the result into the given value.
|
|
func (rdgs *ReportDependencyGraphSelect) Scan(ctx context.Context, v any) error {
|
|
ctx = setContextOp(ctx, rdgs.ctx, ent.OpQuerySelect)
|
|
if err := rdgs.prepareQuery(ctx); err != nil {
|
|
return err
|
|
}
|
|
return scanWithInterceptors[*ReportDependencyGraphQuery, *ReportDependencyGraphSelect](ctx, rdgs.ReportDependencyGraphQuery, rdgs, rdgs.inters, v)
|
|
}
|
|
|
|
func (rdgs *ReportDependencyGraphSelect) sqlScan(ctx context.Context, root *ReportDependencyGraphQuery, v any) error {
|
|
selector := root.sqlQuery(ctx)
|
|
aggregation := make([]string, 0, len(rdgs.fns))
|
|
for _, fn := range rdgs.fns {
|
|
aggregation = append(aggregation, fn(selector))
|
|
}
|
|
switch n := len(*rdgs.selector.flds); {
|
|
case n == 0 && len(aggregation) > 0:
|
|
selector.Select(aggregation...)
|
|
case n != 0 && len(aggregation) > 0:
|
|
selector.AppendSelect(aggregation...)
|
|
}
|
|
rows := &sql.Rows{}
|
|
query, args := selector.Query()
|
|
if err := rdgs.driver.Query(ctx, query, args, rows); err != nil {
|
|
return err
|
|
}
|
|
defer rows.Close()
|
|
return sql.ScanSlice(rows, v)
|
|
}
|