ent.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "reflect"
  8. "sync"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/employee"
  18. "wechat-api/ent/employeeconfig"
  19. "wechat-api/ent/label"
  20. "wechat-api/ent/labelrelationship"
  21. "wechat-api/ent/labeltagging"
  22. "wechat-api/ent/message"
  23. "wechat-api/ent/messagerecords"
  24. "wechat-api/ent/msg"
  25. "wechat-api/ent/server"
  26. "wechat-api/ent/sopnode"
  27. "wechat-api/ent/sopstage"
  28. "wechat-api/ent/soptask"
  29. "wechat-api/ent/token"
  30. "wechat-api/ent/tutorial"
  31. "wechat-api/ent/usagedetail"
  32. "wechat-api/ent/usagestatisticday"
  33. "wechat-api/ent/usagestatistichour"
  34. "wechat-api/ent/usagestatisticmonth"
  35. "wechat-api/ent/usagetotal"
  36. "wechat-api/ent/workexperience"
  37. "wechat-api/ent/wpchatroom"
  38. "wechat-api/ent/wpchatroommember"
  39. "wechat-api/ent/wx"
  40. "wechat-api/ent/wxcard"
  41. "wechat-api/ent/wxcarduser"
  42. "wechat-api/ent/wxcardvisit"
  43. "entgo.io/ent"
  44. "entgo.io/ent/dialect/sql"
  45. "entgo.io/ent/dialect/sql/sqlgraph"
  46. )
  47. // ent aliases to avoid import conflicts in user's code.
  48. type (
  49. Op = ent.Op
  50. Hook = ent.Hook
  51. Value = ent.Value
  52. Query = ent.Query
  53. QueryContext = ent.QueryContext
  54. Querier = ent.Querier
  55. QuerierFunc = ent.QuerierFunc
  56. Interceptor = ent.Interceptor
  57. InterceptFunc = ent.InterceptFunc
  58. Traverser = ent.Traverser
  59. TraverseFunc = ent.TraverseFunc
  60. Policy = ent.Policy
  61. Mutator = ent.Mutator
  62. Mutation = ent.Mutation
  63. MutateFunc = ent.MutateFunc
  64. )
  65. type clientCtxKey struct{}
  66. // FromContext returns a Client stored inside a context, or nil if there isn't one.
  67. func FromContext(ctx context.Context) *Client {
  68. c, _ := ctx.Value(clientCtxKey{}).(*Client)
  69. return c
  70. }
  71. // NewContext returns a new context with the given Client attached.
  72. func NewContext(parent context.Context, c *Client) context.Context {
  73. return context.WithValue(parent, clientCtxKey{}, c)
  74. }
  75. type txCtxKey struct{}
  76. // TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
  77. func TxFromContext(ctx context.Context) *Tx {
  78. tx, _ := ctx.Value(txCtxKey{}).(*Tx)
  79. return tx
  80. }
  81. // NewTxContext returns a new context with the given Tx attached.
  82. func NewTxContext(parent context.Context, tx *Tx) context.Context {
  83. return context.WithValue(parent, txCtxKey{}, tx)
  84. }
  85. // OrderFunc applies an ordering on the sql selector.
  86. // Deprecated: Use Asc/Desc functions or the package builders instead.
  87. type OrderFunc func(*sql.Selector)
  88. var (
  89. initCheck sync.Once
  90. columnCheck sql.ColumnCheck
  91. )
  92. // columnChecker checks if the column exists in the given table.
  93. func checkColumn(table, column string) error {
  94. initCheck.Do(func() {
  95. columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
  96. agent.Table: agent.ValidColumn,
  97. agentbase.Table: agentbase.ValidColumn,
  98. aliyunavatar.Table: aliyunavatar.ValidColumn,
  99. batchmsg.Table: batchmsg.ValidColumn,
  100. category.Table: category.ValidColumn,
  101. chatrecords.Table: chatrecords.ValidColumn,
  102. chatsession.Table: chatsession.ValidColumn,
  103. contact.Table: contact.ValidColumn,
  104. employee.Table: employee.ValidColumn,
  105. employeeconfig.Table: employeeconfig.ValidColumn,
  106. label.Table: label.ValidColumn,
  107. labelrelationship.Table: labelrelationship.ValidColumn,
  108. labeltagging.Table: labeltagging.ValidColumn,
  109. message.Table: message.ValidColumn,
  110. messagerecords.Table: messagerecords.ValidColumn,
  111. msg.Table: msg.ValidColumn,
  112. server.Table: server.ValidColumn,
  113. sopnode.Table: sopnode.ValidColumn,
  114. sopstage.Table: sopstage.ValidColumn,
  115. soptask.Table: soptask.ValidColumn,
  116. token.Table: token.ValidColumn,
  117. tutorial.Table: tutorial.ValidColumn,
  118. usagedetail.Table: usagedetail.ValidColumn,
  119. usagestatisticday.Table: usagestatisticday.ValidColumn,
  120. usagestatistichour.Table: usagestatistichour.ValidColumn,
  121. usagestatisticmonth.Table: usagestatisticmonth.ValidColumn,
  122. usagetotal.Table: usagetotal.ValidColumn,
  123. workexperience.Table: workexperience.ValidColumn,
  124. wpchatroom.Table: wpchatroom.ValidColumn,
  125. wpchatroommember.Table: wpchatroommember.ValidColumn,
  126. wx.Table: wx.ValidColumn,
  127. wxcard.Table: wxcard.ValidColumn,
  128. wxcarduser.Table: wxcarduser.ValidColumn,
  129. wxcardvisit.Table: wxcardvisit.ValidColumn,
  130. })
  131. })
  132. return columnCheck(table, column)
  133. }
  134. // Asc applies the given fields in ASC order.
  135. func Asc(fields ...string) func(*sql.Selector) {
  136. return func(s *sql.Selector) {
  137. for _, f := range fields {
  138. if err := checkColumn(s.TableName(), f); err != nil {
  139. s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
  140. }
  141. s.OrderBy(sql.Asc(s.C(f)))
  142. }
  143. }
  144. }
  145. // Desc applies the given fields in DESC order.
  146. func Desc(fields ...string) func(*sql.Selector) {
  147. return func(s *sql.Selector) {
  148. for _, f := range fields {
  149. if err := checkColumn(s.TableName(), f); err != nil {
  150. s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
  151. }
  152. s.OrderBy(sql.Desc(s.C(f)))
  153. }
  154. }
  155. }
  156. // AggregateFunc applies an aggregation step on the group-by traversal/selector.
  157. type AggregateFunc func(*sql.Selector) string
  158. // As is a pseudo aggregation function for renaming another other functions with custom names. For example:
  159. //
  160. // GroupBy(field1, field2).
  161. // Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
  162. // Scan(ctx, &v)
  163. func As(fn AggregateFunc, end string) AggregateFunc {
  164. return func(s *sql.Selector) string {
  165. return sql.As(fn(s), end)
  166. }
  167. }
  168. // Count applies the "count" aggregation function on each group.
  169. func Count() AggregateFunc {
  170. return func(s *sql.Selector) string {
  171. return sql.Count("*")
  172. }
  173. }
  174. // Max applies the "max" aggregation function on the given field of each group.
  175. func Max(field string) AggregateFunc {
  176. return func(s *sql.Selector) string {
  177. if err := checkColumn(s.TableName(), field); err != nil {
  178. s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
  179. return ""
  180. }
  181. return sql.Max(s.C(field))
  182. }
  183. }
  184. // Mean applies the "mean" aggregation function on the given field of each group.
  185. func Mean(field string) AggregateFunc {
  186. return func(s *sql.Selector) string {
  187. if err := checkColumn(s.TableName(), field); err != nil {
  188. s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
  189. return ""
  190. }
  191. return sql.Avg(s.C(field))
  192. }
  193. }
  194. // Min applies the "min" aggregation function on the given field of each group.
  195. func Min(field string) AggregateFunc {
  196. return func(s *sql.Selector) string {
  197. if err := checkColumn(s.TableName(), field); err != nil {
  198. s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
  199. return ""
  200. }
  201. return sql.Min(s.C(field))
  202. }
  203. }
  204. // Sum applies the "sum" aggregation function on the given field of each group.
  205. func Sum(field string) AggregateFunc {
  206. return func(s *sql.Selector) string {
  207. if err := checkColumn(s.TableName(), field); err != nil {
  208. s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
  209. return ""
  210. }
  211. return sql.Sum(s.C(field))
  212. }
  213. }
  214. // ValidationError returns when validating a field or edge fails.
  215. type ValidationError struct {
  216. Name string // Field or edge name.
  217. err error
  218. }
  219. // Error implements the error interface.
  220. func (e *ValidationError) Error() string {
  221. return e.err.Error()
  222. }
  223. // Unwrap implements the errors.Wrapper interface.
  224. func (e *ValidationError) Unwrap() error {
  225. return e.err
  226. }
  227. // IsValidationError returns a boolean indicating whether the error is a validation error.
  228. func IsValidationError(err error) bool {
  229. if err == nil {
  230. return false
  231. }
  232. var e *ValidationError
  233. return errors.As(err, &e)
  234. }
  235. // NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
  236. type NotFoundError struct {
  237. label string
  238. }
  239. // Error implements the error interface.
  240. func (e *NotFoundError) Error() string {
  241. return "ent: " + e.label + " not found"
  242. }
  243. // IsNotFound returns a boolean indicating whether the error is a not found error.
  244. func IsNotFound(err error) bool {
  245. if err == nil {
  246. return false
  247. }
  248. var e *NotFoundError
  249. return errors.As(err, &e)
  250. }
  251. // MaskNotFound masks not found error.
  252. func MaskNotFound(err error) error {
  253. if IsNotFound(err) {
  254. return nil
  255. }
  256. return err
  257. }
  258. // NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
  259. type NotSingularError struct {
  260. label string
  261. }
  262. // Error implements the error interface.
  263. func (e *NotSingularError) Error() string {
  264. return "ent: " + e.label + " not singular"
  265. }
  266. // IsNotSingular returns a boolean indicating whether the error is a not singular error.
  267. func IsNotSingular(err error) bool {
  268. if err == nil {
  269. return false
  270. }
  271. var e *NotSingularError
  272. return errors.As(err, &e)
  273. }
  274. // NotLoadedError returns when trying to get a node that was not loaded by the query.
  275. type NotLoadedError struct {
  276. edge string
  277. }
  278. // Error implements the error interface.
  279. func (e *NotLoadedError) Error() string {
  280. return "ent: " + e.edge + " edge was not loaded"
  281. }
  282. // IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
  283. func IsNotLoaded(err error) bool {
  284. if err == nil {
  285. return false
  286. }
  287. var e *NotLoadedError
  288. return errors.As(err, &e)
  289. }
  290. // ConstraintError returns when trying to create/update one or more entities and
  291. // one or more of their constraints failed. For example, violation of edge or
  292. // field uniqueness.
  293. type ConstraintError struct {
  294. msg string
  295. wrap error
  296. }
  297. // Error implements the error interface.
  298. func (e ConstraintError) Error() string {
  299. return "ent: constraint failed: " + e.msg
  300. }
  301. // Unwrap implements the errors.Wrapper interface.
  302. func (e *ConstraintError) Unwrap() error {
  303. return e.wrap
  304. }
  305. // IsConstraintError returns a boolean indicating whether the error is a constraint failure.
  306. func IsConstraintError(err error) bool {
  307. if err == nil {
  308. return false
  309. }
  310. var e *ConstraintError
  311. return errors.As(err, &e)
  312. }
  313. // selector embedded by the different Select/GroupBy builders.
  314. type selector struct {
  315. label string
  316. flds *[]string
  317. fns []AggregateFunc
  318. scan func(context.Context, any) error
  319. }
  320. // ScanX is like Scan, but panics if an error occurs.
  321. func (s *selector) ScanX(ctx context.Context, v any) {
  322. if err := s.scan(ctx, v); err != nil {
  323. panic(err)
  324. }
  325. }
  326. // Strings returns list of strings from a selector. It is only allowed when selecting one field.
  327. func (s *selector) Strings(ctx context.Context) ([]string, error) {
  328. if len(*s.flds) > 1 {
  329. return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
  330. }
  331. var v []string
  332. if err := s.scan(ctx, &v); err != nil {
  333. return nil, err
  334. }
  335. return v, nil
  336. }
  337. // StringsX is like Strings, but panics if an error occurs.
  338. func (s *selector) StringsX(ctx context.Context) []string {
  339. v, err := s.Strings(ctx)
  340. if err != nil {
  341. panic(err)
  342. }
  343. return v
  344. }
  345. // String returns a single string from a selector. It is only allowed when selecting one field.
  346. func (s *selector) String(ctx context.Context) (_ string, err error) {
  347. var v []string
  348. if v, err = s.Strings(ctx); err != nil {
  349. return
  350. }
  351. switch len(v) {
  352. case 1:
  353. return v[0], nil
  354. case 0:
  355. err = &NotFoundError{s.label}
  356. default:
  357. err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
  358. }
  359. return
  360. }
  361. // StringX is like String, but panics if an error occurs.
  362. func (s *selector) StringX(ctx context.Context) string {
  363. v, err := s.String(ctx)
  364. if err != nil {
  365. panic(err)
  366. }
  367. return v
  368. }
  369. // Ints returns list of ints from a selector. It is only allowed when selecting one field.
  370. func (s *selector) Ints(ctx context.Context) ([]int, error) {
  371. if len(*s.flds) > 1 {
  372. return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
  373. }
  374. var v []int
  375. if err := s.scan(ctx, &v); err != nil {
  376. return nil, err
  377. }
  378. return v, nil
  379. }
  380. // IntsX is like Ints, but panics if an error occurs.
  381. func (s *selector) IntsX(ctx context.Context) []int {
  382. v, err := s.Ints(ctx)
  383. if err != nil {
  384. panic(err)
  385. }
  386. return v
  387. }
  388. // Int returns a single int from a selector. It is only allowed when selecting one field.
  389. func (s *selector) Int(ctx context.Context) (_ int, err error) {
  390. var v []int
  391. if v, err = s.Ints(ctx); err != nil {
  392. return
  393. }
  394. switch len(v) {
  395. case 1:
  396. return v[0], nil
  397. case 0:
  398. err = &NotFoundError{s.label}
  399. default:
  400. err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
  401. }
  402. return
  403. }
  404. // IntX is like Int, but panics if an error occurs.
  405. func (s *selector) IntX(ctx context.Context) int {
  406. v, err := s.Int(ctx)
  407. if err != nil {
  408. panic(err)
  409. }
  410. return v
  411. }
  412. // Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
  413. func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
  414. if len(*s.flds) > 1 {
  415. return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
  416. }
  417. var v []float64
  418. if err := s.scan(ctx, &v); err != nil {
  419. return nil, err
  420. }
  421. return v, nil
  422. }
  423. // Float64sX is like Float64s, but panics if an error occurs.
  424. func (s *selector) Float64sX(ctx context.Context) []float64 {
  425. v, err := s.Float64s(ctx)
  426. if err != nil {
  427. panic(err)
  428. }
  429. return v
  430. }
  431. // Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
  432. func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
  433. var v []float64
  434. if v, err = s.Float64s(ctx); err != nil {
  435. return
  436. }
  437. switch len(v) {
  438. case 1:
  439. return v[0], nil
  440. case 0:
  441. err = &NotFoundError{s.label}
  442. default:
  443. err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
  444. }
  445. return
  446. }
  447. // Float64X is like Float64, but panics if an error occurs.
  448. func (s *selector) Float64X(ctx context.Context) float64 {
  449. v, err := s.Float64(ctx)
  450. if err != nil {
  451. panic(err)
  452. }
  453. return v
  454. }
  455. // Bools returns list of bools from a selector. It is only allowed when selecting one field.
  456. func (s *selector) Bools(ctx context.Context) ([]bool, error) {
  457. if len(*s.flds) > 1 {
  458. return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
  459. }
  460. var v []bool
  461. if err := s.scan(ctx, &v); err != nil {
  462. return nil, err
  463. }
  464. return v, nil
  465. }
  466. // BoolsX is like Bools, but panics if an error occurs.
  467. func (s *selector) BoolsX(ctx context.Context) []bool {
  468. v, err := s.Bools(ctx)
  469. if err != nil {
  470. panic(err)
  471. }
  472. return v
  473. }
  474. // Bool returns a single bool from a selector. It is only allowed when selecting one field.
  475. func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
  476. var v []bool
  477. if v, err = s.Bools(ctx); err != nil {
  478. return
  479. }
  480. switch len(v) {
  481. case 1:
  482. return v[0], nil
  483. case 0:
  484. err = &NotFoundError{s.label}
  485. default:
  486. err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
  487. }
  488. return
  489. }
  490. // BoolX is like Bool, but panics if an error occurs.
  491. func (s *selector) BoolX(ctx context.Context) bool {
  492. v, err := s.Bool(ctx)
  493. if err != nil {
  494. panic(err)
  495. }
  496. return v
  497. }
  498. // withHooks invokes the builder operation with the given hooks, if any.
  499. func withHooks[V Value, M any, PM interface {
  500. *M
  501. Mutation
  502. }](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
  503. if len(hooks) == 0 {
  504. return exec(ctx)
  505. }
  506. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  507. mutationT, ok := any(m).(PM)
  508. if !ok {
  509. return nil, fmt.Errorf("unexpected mutation type %T", m)
  510. }
  511. // Set the mutation to the builder.
  512. *mutation = *mutationT
  513. return exec(ctx)
  514. })
  515. for i := len(hooks) - 1; i >= 0; i-- {
  516. if hooks[i] == nil {
  517. return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
  518. }
  519. mut = hooks[i](mut)
  520. }
  521. v, err := mut.Mutate(ctx, mutation)
  522. if err != nil {
  523. return value, err
  524. }
  525. nv, ok := v.(V)
  526. if !ok {
  527. return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
  528. }
  529. return nv, nil
  530. }
  531. // setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
  532. func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
  533. if ent.QueryFromContext(ctx) == nil {
  534. qc.Op = op
  535. ctx = ent.NewQueryContext(ctx, qc)
  536. }
  537. return ctx
  538. }
  539. func querierAll[V Value, Q interface {
  540. sqlAll(context.Context, ...queryHook) (V, error)
  541. }]() Querier {
  542. return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
  543. query, ok := q.(Q)
  544. if !ok {
  545. return nil, fmt.Errorf("unexpected query type %T", q)
  546. }
  547. return query.sqlAll(ctx)
  548. })
  549. }
  550. func querierCount[Q interface {
  551. sqlCount(context.Context) (int, error)
  552. }]() Querier {
  553. return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
  554. query, ok := q.(Q)
  555. if !ok {
  556. return nil, fmt.Errorf("unexpected query type %T", q)
  557. }
  558. return query.sqlCount(ctx)
  559. })
  560. }
  561. func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
  562. for i := len(inters) - 1; i >= 0; i-- {
  563. qr = inters[i].Intercept(qr)
  564. }
  565. rv, err := qr.Query(ctx, q)
  566. if err != nil {
  567. return v, err
  568. }
  569. vt, ok := rv.(V)
  570. if !ok {
  571. return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
  572. }
  573. return vt, nil
  574. }
  575. func scanWithInterceptors[Q1 ent.Query, Q2 interface {
  576. sqlScan(context.Context, Q1, any) error
  577. }](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
  578. rv := reflect.ValueOf(v)
  579. var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
  580. query, ok := q.(Q1)
  581. if !ok {
  582. return nil, fmt.Errorf("unexpected query type %T", q)
  583. }
  584. if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
  585. return nil, err
  586. }
  587. if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
  588. return rv.Elem().Interface(), nil
  589. }
  590. return v, nil
  591. })
  592. for i := len(inters) - 1; i >= 0; i-- {
  593. qr = inters[i].Intercept(qr)
  594. }
  595. vv, err := qr.Query(ctx, rootQuery)
  596. if err != nil {
  597. return err
  598. }
  599. switch rv2 := reflect.ValueOf(vv); {
  600. case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
  601. case rv.Type() == rv2.Type():
  602. rv.Elem().Set(rv2.Elem())
  603. case rv.Elem().Type() == rv2.Type():
  604. rv.Elem().Set(rv2)
  605. }
  606. return nil
  607. }
  608. // queryHook describes an internal hook for the different sqlAll methods.
  609. type queryHook func(context.Context, *sqlgraph.QuerySpec)