soptask_query.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "database/sql/driver"
  6. "fmt"
  7. "math"
  8. "wechat-api/ent/predicate"
  9. "wechat-api/ent/sopstage"
  10. "wechat-api/ent/soptask"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/schema/field"
  14. )
  15. // SopTaskQuery is the builder for querying SopTask entities.
  16. type SopTaskQuery struct {
  17. config
  18. ctx *QueryContext
  19. order []soptask.OrderOption
  20. inters []Interceptor
  21. predicates []predicate.SopTask
  22. withTaskStages *SopStageQuery
  23. // intermediate query (i.e. traversal path).
  24. sql *sql.Selector
  25. path func(context.Context) (*sql.Selector, error)
  26. }
  27. // Where adds a new predicate for the SopTaskQuery builder.
  28. func (stq *SopTaskQuery) Where(ps ...predicate.SopTask) *SopTaskQuery {
  29. stq.predicates = append(stq.predicates, ps...)
  30. return stq
  31. }
  32. // Limit the number of records to be returned by this query.
  33. func (stq *SopTaskQuery) Limit(limit int) *SopTaskQuery {
  34. stq.ctx.Limit = &limit
  35. return stq
  36. }
  37. // Offset to start from.
  38. func (stq *SopTaskQuery) Offset(offset int) *SopTaskQuery {
  39. stq.ctx.Offset = &offset
  40. return stq
  41. }
  42. // Unique configures the query builder to filter duplicate records on query.
  43. // By default, unique is set to true, and can be disabled using this method.
  44. func (stq *SopTaskQuery) Unique(unique bool) *SopTaskQuery {
  45. stq.ctx.Unique = &unique
  46. return stq
  47. }
  48. // Order specifies how the records should be ordered.
  49. func (stq *SopTaskQuery) Order(o ...soptask.OrderOption) *SopTaskQuery {
  50. stq.order = append(stq.order, o...)
  51. return stq
  52. }
  53. // QueryTaskStages chains the current query on the "task_stages" edge.
  54. func (stq *SopTaskQuery) QueryTaskStages() *SopStageQuery {
  55. query := (&SopStageClient{config: stq.config}).Query()
  56. query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
  57. if err := stq.prepareQuery(ctx); err != nil {
  58. return nil, err
  59. }
  60. selector := stq.sqlQuery(ctx)
  61. if err := selector.Err(); err != nil {
  62. return nil, err
  63. }
  64. step := sqlgraph.NewStep(
  65. sqlgraph.From(soptask.Table, soptask.FieldID, selector),
  66. sqlgraph.To(sopstage.Table, sopstage.FieldID),
  67. sqlgraph.Edge(sqlgraph.O2M, false, soptask.TaskStagesTable, soptask.TaskStagesColumn),
  68. )
  69. fromU = sqlgraph.SetNeighbors(stq.driver.Dialect(), step)
  70. return fromU, nil
  71. }
  72. return query
  73. }
  74. // First returns the first SopTask entity from the query.
  75. // Returns a *NotFoundError when no SopTask was found.
  76. func (stq *SopTaskQuery) First(ctx context.Context) (*SopTask, error) {
  77. nodes, err := stq.Limit(1).All(setContextOp(ctx, stq.ctx, "First"))
  78. if err != nil {
  79. return nil, err
  80. }
  81. if len(nodes) == 0 {
  82. return nil, &NotFoundError{soptask.Label}
  83. }
  84. return nodes[0], nil
  85. }
  86. // FirstX is like First, but panics if an error occurs.
  87. func (stq *SopTaskQuery) FirstX(ctx context.Context) *SopTask {
  88. node, err := stq.First(ctx)
  89. if err != nil && !IsNotFound(err) {
  90. panic(err)
  91. }
  92. return node
  93. }
  94. // FirstID returns the first SopTask ID from the query.
  95. // Returns a *NotFoundError when no SopTask ID was found.
  96. func (stq *SopTaskQuery) FirstID(ctx context.Context) (id uint64, err error) {
  97. var ids []uint64
  98. if ids, err = stq.Limit(1).IDs(setContextOp(ctx, stq.ctx, "FirstID")); err != nil {
  99. return
  100. }
  101. if len(ids) == 0 {
  102. err = &NotFoundError{soptask.Label}
  103. return
  104. }
  105. return ids[0], nil
  106. }
  107. // FirstIDX is like FirstID, but panics if an error occurs.
  108. func (stq *SopTaskQuery) FirstIDX(ctx context.Context) uint64 {
  109. id, err := stq.FirstID(ctx)
  110. if err != nil && !IsNotFound(err) {
  111. panic(err)
  112. }
  113. return id
  114. }
  115. // Only returns a single SopTask entity found by the query, ensuring it only returns one.
  116. // Returns a *NotSingularError when more than one SopTask entity is found.
  117. // Returns a *NotFoundError when no SopTask entities are found.
  118. func (stq *SopTaskQuery) Only(ctx context.Context) (*SopTask, error) {
  119. nodes, err := stq.Limit(2).All(setContextOp(ctx, stq.ctx, "Only"))
  120. if err != nil {
  121. return nil, err
  122. }
  123. switch len(nodes) {
  124. case 1:
  125. return nodes[0], nil
  126. case 0:
  127. return nil, &NotFoundError{soptask.Label}
  128. default:
  129. return nil, &NotSingularError{soptask.Label}
  130. }
  131. }
  132. // OnlyX is like Only, but panics if an error occurs.
  133. func (stq *SopTaskQuery) OnlyX(ctx context.Context) *SopTask {
  134. node, err := stq.Only(ctx)
  135. if err != nil {
  136. panic(err)
  137. }
  138. return node
  139. }
  140. // OnlyID is like Only, but returns the only SopTask ID in the query.
  141. // Returns a *NotSingularError when more than one SopTask ID is found.
  142. // Returns a *NotFoundError when no entities are found.
  143. func (stq *SopTaskQuery) OnlyID(ctx context.Context) (id uint64, err error) {
  144. var ids []uint64
  145. if ids, err = stq.Limit(2).IDs(setContextOp(ctx, stq.ctx, "OnlyID")); err != nil {
  146. return
  147. }
  148. switch len(ids) {
  149. case 1:
  150. id = ids[0]
  151. case 0:
  152. err = &NotFoundError{soptask.Label}
  153. default:
  154. err = &NotSingularError{soptask.Label}
  155. }
  156. return
  157. }
  158. // OnlyIDX is like OnlyID, but panics if an error occurs.
  159. func (stq *SopTaskQuery) OnlyIDX(ctx context.Context) uint64 {
  160. id, err := stq.OnlyID(ctx)
  161. if err != nil {
  162. panic(err)
  163. }
  164. return id
  165. }
  166. // All executes the query and returns a list of SopTasks.
  167. func (stq *SopTaskQuery) All(ctx context.Context) ([]*SopTask, error) {
  168. ctx = setContextOp(ctx, stq.ctx, "All")
  169. if err := stq.prepareQuery(ctx); err != nil {
  170. return nil, err
  171. }
  172. qr := querierAll[[]*SopTask, *SopTaskQuery]()
  173. return withInterceptors[[]*SopTask](ctx, stq, qr, stq.inters)
  174. }
  175. // AllX is like All, but panics if an error occurs.
  176. func (stq *SopTaskQuery) AllX(ctx context.Context) []*SopTask {
  177. nodes, err := stq.All(ctx)
  178. if err != nil {
  179. panic(err)
  180. }
  181. return nodes
  182. }
  183. // IDs executes the query and returns a list of SopTask IDs.
  184. func (stq *SopTaskQuery) IDs(ctx context.Context) (ids []uint64, err error) {
  185. if stq.ctx.Unique == nil && stq.path != nil {
  186. stq.Unique(true)
  187. }
  188. ctx = setContextOp(ctx, stq.ctx, "IDs")
  189. if err = stq.Select(soptask.FieldID).Scan(ctx, &ids); err != nil {
  190. return nil, err
  191. }
  192. return ids, nil
  193. }
  194. // IDsX is like IDs, but panics if an error occurs.
  195. func (stq *SopTaskQuery) IDsX(ctx context.Context) []uint64 {
  196. ids, err := stq.IDs(ctx)
  197. if err != nil {
  198. panic(err)
  199. }
  200. return ids
  201. }
  202. // Count returns the count of the given query.
  203. func (stq *SopTaskQuery) Count(ctx context.Context) (int, error) {
  204. ctx = setContextOp(ctx, stq.ctx, "Count")
  205. if err := stq.prepareQuery(ctx); err != nil {
  206. return 0, err
  207. }
  208. return withInterceptors[int](ctx, stq, querierCount[*SopTaskQuery](), stq.inters)
  209. }
  210. // CountX is like Count, but panics if an error occurs.
  211. func (stq *SopTaskQuery) CountX(ctx context.Context) int {
  212. count, err := stq.Count(ctx)
  213. if err != nil {
  214. panic(err)
  215. }
  216. return count
  217. }
  218. // Exist returns true if the query has elements in the graph.
  219. func (stq *SopTaskQuery) Exist(ctx context.Context) (bool, error) {
  220. ctx = setContextOp(ctx, stq.ctx, "Exist")
  221. switch _, err := stq.FirstID(ctx); {
  222. case IsNotFound(err):
  223. return false, nil
  224. case err != nil:
  225. return false, fmt.Errorf("ent: check existence: %w", err)
  226. default:
  227. return true, nil
  228. }
  229. }
  230. // ExistX is like Exist, but panics if an error occurs.
  231. func (stq *SopTaskQuery) ExistX(ctx context.Context) bool {
  232. exist, err := stq.Exist(ctx)
  233. if err != nil {
  234. panic(err)
  235. }
  236. return exist
  237. }
  238. // Clone returns a duplicate of the SopTaskQuery builder, including all associated steps. It can be
  239. // used to prepare common query builders and use them differently after the clone is made.
  240. func (stq *SopTaskQuery) Clone() *SopTaskQuery {
  241. if stq == nil {
  242. return nil
  243. }
  244. return &SopTaskQuery{
  245. config: stq.config,
  246. ctx: stq.ctx.Clone(),
  247. order: append([]soptask.OrderOption{}, stq.order...),
  248. inters: append([]Interceptor{}, stq.inters...),
  249. predicates: append([]predicate.SopTask{}, stq.predicates...),
  250. withTaskStages: stq.withTaskStages.Clone(),
  251. // clone intermediate query.
  252. sql: stq.sql.Clone(),
  253. path: stq.path,
  254. }
  255. }
  256. // WithTaskStages tells the query-builder to eager-load the nodes that are connected to
  257. // the "task_stages" edge. The optional arguments are used to configure the query builder of the edge.
  258. func (stq *SopTaskQuery) WithTaskStages(opts ...func(*SopStageQuery)) *SopTaskQuery {
  259. query := (&SopStageClient{config: stq.config}).Query()
  260. for _, opt := range opts {
  261. opt(query)
  262. }
  263. stq.withTaskStages = query
  264. return stq
  265. }
  266. // GroupBy is used to group vertices by one or more fields/columns.
  267. // It is often used with aggregate functions, like: count, max, mean, min, sum.
  268. //
  269. // Example:
  270. //
  271. // var v []struct {
  272. // CreatedAt time.Time `json:"created_at,omitempty"`
  273. // Count int `json:"count,omitempty"`
  274. // }
  275. //
  276. // client.SopTask.Query().
  277. // GroupBy(soptask.FieldCreatedAt).
  278. // Aggregate(ent.Count()).
  279. // Scan(ctx, &v)
  280. func (stq *SopTaskQuery) GroupBy(field string, fields ...string) *SopTaskGroupBy {
  281. stq.ctx.Fields = append([]string{field}, fields...)
  282. grbuild := &SopTaskGroupBy{build: stq}
  283. grbuild.flds = &stq.ctx.Fields
  284. grbuild.label = soptask.Label
  285. grbuild.scan = grbuild.Scan
  286. return grbuild
  287. }
  288. // Select allows the selection one or more fields/columns for the given query,
  289. // instead of selecting all fields in the entity.
  290. //
  291. // Example:
  292. //
  293. // var v []struct {
  294. // CreatedAt time.Time `json:"created_at,omitempty"`
  295. // }
  296. //
  297. // client.SopTask.Query().
  298. // Select(soptask.FieldCreatedAt).
  299. // Scan(ctx, &v)
  300. func (stq *SopTaskQuery) Select(fields ...string) *SopTaskSelect {
  301. stq.ctx.Fields = append(stq.ctx.Fields, fields...)
  302. sbuild := &SopTaskSelect{SopTaskQuery: stq}
  303. sbuild.label = soptask.Label
  304. sbuild.flds, sbuild.scan = &stq.ctx.Fields, sbuild.Scan
  305. return sbuild
  306. }
  307. // Aggregate returns a SopTaskSelect configured with the given aggregations.
  308. func (stq *SopTaskQuery) Aggregate(fns ...AggregateFunc) *SopTaskSelect {
  309. return stq.Select().Aggregate(fns...)
  310. }
  311. func (stq *SopTaskQuery) prepareQuery(ctx context.Context) error {
  312. for _, inter := range stq.inters {
  313. if inter == nil {
  314. return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
  315. }
  316. if trv, ok := inter.(Traverser); ok {
  317. if err := trv.Traverse(ctx, stq); err != nil {
  318. return err
  319. }
  320. }
  321. }
  322. for _, f := range stq.ctx.Fields {
  323. if !soptask.ValidColumn(f) {
  324. return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  325. }
  326. }
  327. if stq.path != nil {
  328. prev, err := stq.path(ctx)
  329. if err != nil {
  330. return err
  331. }
  332. stq.sql = prev
  333. }
  334. return nil
  335. }
  336. func (stq *SopTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SopTask, error) {
  337. var (
  338. nodes = []*SopTask{}
  339. _spec = stq.querySpec()
  340. loadedTypes = [1]bool{
  341. stq.withTaskStages != nil,
  342. }
  343. )
  344. _spec.ScanValues = func(columns []string) ([]any, error) {
  345. return (*SopTask).scanValues(nil, columns)
  346. }
  347. _spec.Assign = func(columns []string, values []any) error {
  348. node := &SopTask{config: stq.config}
  349. nodes = append(nodes, node)
  350. node.Edges.loadedTypes = loadedTypes
  351. return node.assignValues(columns, values)
  352. }
  353. for i := range hooks {
  354. hooks[i](ctx, _spec)
  355. }
  356. if err := sqlgraph.QueryNodes(ctx, stq.driver, _spec); err != nil {
  357. return nil, err
  358. }
  359. if len(nodes) == 0 {
  360. return nodes, nil
  361. }
  362. if query := stq.withTaskStages; query != nil {
  363. if err := stq.loadTaskStages(ctx, query, nodes,
  364. func(n *SopTask) { n.Edges.TaskStages = []*SopStage{} },
  365. func(n *SopTask, e *SopStage) { n.Edges.TaskStages = append(n.Edges.TaskStages, e) }); err != nil {
  366. return nil, err
  367. }
  368. }
  369. return nodes, nil
  370. }
  371. func (stq *SopTaskQuery) loadTaskStages(ctx context.Context, query *SopStageQuery, nodes []*SopTask, init func(*SopTask), assign func(*SopTask, *SopStage)) error {
  372. fks := make([]driver.Value, 0, len(nodes))
  373. nodeids := make(map[uint64]*SopTask)
  374. for i := range nodes {
  375. fks = append(fks, nodes[i].ID)
  376. nodeids[nodes[i].ID] = nodes[i]
  377. if init != nil {
  378. init(nodes[i])
  379. }
  380. }
  381. if len(query.ctx.Fields) > 0 {
  382. query.ctx.AppendFieldOnce(sopstage.FieldTaskID)
  383. }
  384. query.Where(predicate.SopStage(func(s *sql.Selector) {
  385. s.Where(sql.InValues(s.C(soptask.TaskStagesColumn), fks...))
  386. }))
  387. neighbors, err := query.All(ctx)
  388. if err != nil {
  389. return err
  390. }
  391. for _, n := range neighbors {
  392. fk := n.TaskID
  393. node, ok := nodeids[fk]
  394. if !ok {
  395. return fmt.Errorf(`unexpected referenced foreign-key "task_id" returned %v for node %v`, fk, n.ID)
  396. }
  397. assign(node, n)
  398. }
  399. return nil
  400. }
  401. func (stq *SopTaskQuery) sqlCount(ctx context.Context) (int, error) {
  402. _spec := stq.querySpec()
  403. _spec.Node.Columns = stq.ctx.Fields
  404. if len(stq.ctx.Fields) > 0 {
  405. _spec.Unique = stq.ctx.Unique != nil && *stq.ctx.Unique
  406. }
  407. return sqlgraph.CountNodes(ctx, stq.driver, _spec)
  408. }
  409. func (stq *SopTaskQuery) querySpec() *sqlgraph.QuerySpec {
  410. _spec := sqlgraph.NewQuerySpec(soptask.Table, soptask.Columns, sqlgraph.NewFieldSpec(soptask.FieldID, field.TypeUint64))
  411. _spec.From = stq.sql
  412. if unique := stq.ctx.Unique; unique != nil {
  413. _spec.Unique = *unique
  414. } else if stq.path != nil {
  415. _spec.Unique = true
  416. }
  417. if fields := stq.ctx.Fields; len(fields) > 0 {
  418. _spec.Node.Columns = make([]string, 0, len(fields))
  419. _spec.Node.Columns = append(_spec.Node.Columns, soptask.FieldID)
  420. for i := range fields {
  421. if fields[i] != soptask.FieldID {
  422. _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
  423. }
  424. }
  425. }
  426. if ps := stq.predicates; len(ps) > 0 {
  427. _spec.Predicate = func(selector *sql.Selector) {
  428. for i := range ps {
  429. ps[i](selector)
  430. }
  431. }
  432. }
  433. if limit := stq.ctx.Limit; limit != nil {
  434. _spec.Limit = *limit
  435. }
  436. if offset := stq.ctx.Offset; offset != nil {
  437. _spec.Offset = *offset
  438. }
  439. if ps := stq.order; len(ps) > 0 {
  440. _spec.Order = func(selector *sql.Selector) {
  441. for i := range ps {
  442. ps[i](selector)
  443. }
  444. }
  445. }
  446. return _spec
  447. }
  448. func (stq *SopTaskQuery) sqlQuery(ctx context.Context) *sql.Selector {
  449. builder := sql.Dialect(stq.driver.Dialect())
  450. t1 := builder.Table(soptask.Table)
  451. columns := stq.ctx.Fields
  452. if len(columns) == 0 {
  453. columns = soptask.Columns
  454. }
  455. selector := builder.Select(t1.Columns(columns...)...).From(t1)
  456. if stq.sql != nil {
  457. selector = stq.sql
  458. selector.Select(selector.Columns(columns...)...)
  459. }
  460. if stq.ctx.Unique != nil && *stq.ctx.Unique {
  461. selector.Distinct()
  462. }
  463. for _, p := range stq.predicates {
  464. p(selector)
  465. }
  466. for _, p := range stq.order {
  467. p(selector)
  468. }
  469. if offset := stq.ctx.Offset; offset != nil {
  470. // limit is mandatory for offset clause. We start
  471. // with default value, and override it below if needed.
  472. selector.Offset(*offset).Limit(math.MaxInt32)
  473. }
  474. if limit := stq.ctx.Limit; limit != nil {
  475. selector.Limit(*limit)
  476. }
  477. return selector
  478. }
  479. // SopTaskGroupBy is the group-by builder for SopTask entities.
  480. type SopTaskGroupBy struct {
  481. selector
  482. build *SopTaskQuery
  483. }
  484. // Aggregate adds the given aggregation functions to the group-by query.
  485. func (stgb *SopTaskGroupBy) Aggregate(fns ...AggregateFunc) *SopTaskGroupBy {
  486. stgb.fns = append(stgb.fns, fns...)
  487. return stgb
  488. }
  489. // Scan applies the selector query and scans the result into the given value.
  490. func (stgb *SopTaskGroupBy) Scan(ctx context.Context, v any) error {
  491. ctx = setContextOp(ctx, stgb.build.ctx, "GroupBy")
  492. if err := stgb.build.prepareQuery(ctx); err != nil {
  493. return err
  494. }
  495. return scanWithInterceptors[*SopTaskQuery, *SopTaskGroupBy](ctx, stgb.build, stgb, stgb.build.inters, v)
  496. }
  497. func (stgb *SopTaskGroupBy) sqlScan(ctx context.Context, root *SopTaskQuery, v any) error {
  498. selector := root.sqlQuery(ctx).Select()
  499. aggregation := make([]string, 0, len(stgb.fns))
  500. for _, fn := range stgb.fns {
  501. aggregation = append(aggregation, fn(selector))
  502. }
  503. if len(selector.SelectedColumns()) == 0 {
  504. columns := make([]string, 0, len(*stgb.flds)+len(stgb.fns))
  505. for _, f := range *stgb.flds {
  506. columns = append(columns, selector.C(f))
  507. }
  508. columns = append(columns, aggregation...)
  509. selector.Select(columns...)
  510. }
  511. selector.GroupBy(selector.Columns(*stgb.flds...)...)
  512. if err := selector.Err(); err != nil {
  513. return err
  514. }
  515. rows := &sql.Rows{}
  516. query, args := selector.Query()
  517. if err := stgb.build.driver.Query(ctx, query, args, rows); err != nil {
  518. return err
  519. }
  520. defer rows.Close()
  521. return sql.ScanSlice(rows, v)
  522. }
  523. // SopTaskSelect is the builder for selecting fields of SopTask entities.
  524. type SopTaskSelect struct {
  525. *SopTaskQuery
  526. selector
  527. }
  528. // Aggregate adds the given aggregation functions to the selector query.
  529. func (sts *SopTaskSelect) Aggregate(fns ...AggregateFunc) *SopTaskSelect {
  530. sts.fns = append(sts.fns, fns...)
  531. return sts
  532. }
  533. // Scan applies the selector query and scans the result into the given value.
  534. func (sts *SopTaskSelect) Scan(ctx context.Context, v any) error {
  535. ctx = setContextOp(ctx, sts.ctx, "Select")
  536. if err := sts.prepareQuery(ctx); err != nil {
  537. return err
  538. }
  539. return scanWithInterceptors[*SopTaskQuery, *SopTaskSelect](ctx, sts.SopTaskQuery, sts, sts.inters, v)
  540. }
  541. func (sts *SopTaskSelect) sqlScan(ctx context.Context, root *SopTaskQuery, v any) error {
  542. selector := root.sqlQuery(ctx)
  543. aggregation := make([]string, 0, len(sts.fns))
  544. for _, fn := range sts.fns {
  545. aggregation = append(aggregation, fn(selector))
  546. }
  547. switch n := len(*sts.selector.flds); {
  548. case n == 0 && len(aggregation) > 0:
  549. selector.Select(aggregation...)
  550. case n != 0 && len(aggregation) > 0:
  551. selector.AppendSelect(aggregation...)
  552. }
  553. rows := &sql.Rows{}
  554. query, args := selector.Query()
  555. if err := sts.driver.Query(ctx, query, args, rows); err != nil {
  556. return err
  557. }
  558. defer rows.Close()
  559. return sql.ScanSlice(rows, v)
  560. }