car_query.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. // Code generated by entc, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "math"
  8. "code.osinet.fr/fgm/entdemo/ent/car"
  9. "code.osinet.fr/fgm/entdemo/ent/predicate"
  10. "code.osinet.fr/fgm/entdemo/ent/user"
  11. "github.com/facebookincubator/ent/dialect/sql"
  12. "github.com/facebookincubator/ent/dialect/sql/sqlgraph"
  13. "github.com/facebookincubator/ent/schema/field"
  14. )
  15. // CarQuery is the builder for querying Car entities.
  16. type CarQuery struct {
  17. config
  18. limit *int
  19. offset *int
  20. order []Order
  21. unique []string
  22. predicates []predicate.Car
  23. // eager-loading edges.
  24. withOwner *UserQuery
  25. withFKs bool
  26. // intermediate query.
  27. sql *sql.Selector
  28. }
  29. // Where adds a new predicate for the builder.
  30. func (cq *CarQuery) Where(ps ...predicate.Car) *CarQuery {
  31. cq.predicates = append(cq.predicates, ps...)
  32. return cq
  33. }
  34. // Limit adds a limit step to the query.
  35. func (cq *CarQuery) Limit(limit int) *CarQuery {
  36. cq.limit = &limit
  37. return cq
  38. }
  39. // Offset adds an offset step to the query.
  40. func (cq *CarQuery) Offset(offset int) *CarQuery {
  41. cq.offset = &offset
  42. return cq
  43. }
  44. // Order adds an order step to the query.
  45. func (cq *CarQuery) Order(o ...Order) *CarQuery {
  46. cq.order = append(cq.order, o...)
  47. return cq
  48. }
  49. // QueryOwner chains the current query on the owner edge.
  50. func (cq *CarQuery) QueryOwner() *UserQuery {
  51. query := &UserQuery{config: cq.config}
  52. step := sqlgraph.NewStep(
  53. sqlgraph.From(car.Table, car.FieldID, cq.sqlQuery()),
  54. sqlgraph.To(user.Table, user.FieldID),
  55. sqlgraph.Edge(sqlgraph.M2O, true, car.OwnerTable, car.OwnerColumn),
  56. )
  57. query.sql = sqlgraph.SetNeighbors(cq.driver.Dialect(), step)
  58. return query
  59. }
  60. // First returns the first Car entity in the query. Returns *NotFoundError when no car was found.
  61. func (cq *CarQuery) First(ctx context.Context) (*Car, error) {
  62. cs, err := cq.Limit(1).All(ctx)
  63. if err != nil {
  64. return nil, err
  65. }
  66. if len(cs) == 0 {
  67. return nil, &NotFoundError{car.Label}
  68. }
  69. return cs[0], nil
  70. }
  71. // FirstX is like First, but panics if an error occurs.
  72. func (cq *CarQuery) FirstX(ctx context.Context) *Car {
  73. c, err := cq.First(ctx)
  74. if err != nil && !IsNotFound(err) {
  75. panic(err)
  76. }
  77. return c
  78. }
  79. // FirstID returns the first Car id in the query. Returns *NotFoundError when no id was found.
  80. func (cq *CarQuery) FirstID(ctx context.Context) (id int, err error) {
  81. var ids []int
  82. if ids, err = cq.Limit(1).IDs(ctx); err != nil {
  83. return
  84. }
  85. if len(ids) == 0 {
  86. err = &NotFoundError{car.Label}
  87. return
  88. }
  89. return ids[0], nil
  90. }
  91. // FirstXID is like FirstID, but panics if an error occurs.
  92. func (cq *CarQuery) FirstXID(ctx context.Context) int {
  93. id, err := cq.FirstID(ctx)
  94. if err != nil && !IsNotFound(err) {
  95. panic(err)
  96. }
  97. return id
  98. }
  99. // Only returns the only Car entity in the query, returns an error if not exactly one entity was returned.
  100. func (cq *CarQuery) Only(ctx context.Context) (*Car, error) {
  101. cs, err := cq.Limit(2).All(ctx)
  102. if err != nil {
  103. return nil, err
  104. }
  105. switch len(cs) {
  106. case 1:
  107. return cs[0], nil
  108. case 0:
  109. return nil, &NotFoundError{car.Label}
  110. default:
  111. return nil, &NotSingularError{car.Label}
  112. }
  113. }
  114. // OnlyX is like Only, but panics if an error occurs.
  115. func (cq *CarQuery) OnlyX(ctx context.Context) *Car {
  116. c, err := cq.Only(ctx)
  117. if err != nil {
  118. panic(err)
  119. }
  120. return c
  121. }
  122. // OnlyID returns the only Car id in the query, returns an error if not exactly one id was returned.
  123. func (cq *CarQuery) OnlyID(ctx context.Context) (id int, err error) {
  124. var ids []int
  125. if ids, err = cq.Limit(2).IDs(ctx); err != nil {
  126. return
  127. }
  128. switch len(ids) {
  129. case 1:
  130. id = ids[0]
  131. case 0:
  132. err = &NotFoundError{car.Label}
  133. default:
  134. err = &NotSingularError{car.Label}
  135. }
  136. return
  137. }
  138. // OnlyXID is like OnlyID, but panics if an error occurs.
  139. func (cq *CarQuery) OnlyXID(ctx context.Context) int {
  140. id, err := cq.OnlyID(ctx)
  141. if err != nil {
  142. panic(err)
  143. }
  144. return id
  145. }
  146. // All executes the query and returns a list of Cars.
  147. func (cq *CarQuery) All(ctx context.Context) ([]*Car, error) {
  148. return cq.sqlAll(ctx)
  149. }
  150. // AllX is like All, but panics if an error occurs.
  151. func (cq *CarQuery) AllX(ctx context.Context) []*Car {
  152. cs, err := cq.All(ctx)
  153. if err != nil {
  154. panic(err)
  155. }
  156. return cs
  157. }
  158. // IDs executes the query and returns a list of Car ids.
  159. func (cq *CarQuery) IDs(ctx context.Context) ([]int, error) {
  160. var ids []int
  161. if err := cq.Select(car.FieldID).Scan(ctx, &ids); err != nil {
  162. return nil, err
  163. }
  164. return ids, nil
  165. }
  166. // IDsX is like IDs, but panics if an error occurs.
  167. func (cq *CarQuery) IDsX(ctx context.Context) []int {
  168. ids, err := cq.IDs(ctx)
  169. if err != nil {
  170. panic(err)
  171. }
  172. return ids
  173. }
  174. // Count returns the count of the given query.
  175. func (cq *CarQuery) Count(ctx context.Context) (int, error) {
  176. return cq.sqlCount(ctx)
  177. }
  178. // CountX is like Count, but panics if an error occurs.
  179. func (cq *CarQuery) CountX(ctx context.Context) int {
  180. count, err := cq.Count(ctx)
  181. if err != nil {
  182. panic(err)
  183. }
  184. return count
  185. }
  186. // Exist returns true if the query has elements in the graph.
  187. func (cq *CarQuery) Exist(ctx context.Context) (bool, error) {
  188. return cq.sqlExist(ctx)
  189. }
  190. // ExistX is like Exist, but panics if an error occurs.
  191. func (cq *CarQuery) ExistX(ctx context.Context) bool {
  192. exist, err := cq.Exist(ctx)
  193. if err != nil {
  194. panic(err)
  195. }
  196. return exist
  197. }
  198. // Clone returns a duplicate of the query builder, including all associated steps. It can be
  199. // used to prepare common query builders and use them differently after the clone is made.
  200. func (cq *CarQuery) Clone() *CarQuery {
  201. return &CarQuery{
  202. config: cq.config,
  203. limit: cq.limit,
  204. offset: cq.offset,
  205. order: append([]Order{}, cq.order...),
  206. unique: append([]string{}, cq.unique...),
  207. predicates: append([]predicate.Car{}, cq.predicates...),
  208. // clone intermediate query.
  209. sql: cq.sql.Clone(),
  210. }
  211. }
  212. // WithOwner tells the query-builder to eager-loads the nodes that are connected to
  213. // the "owner" edge. The optional arguments used to configure the query builder of the edge.
  214. func (cq *CarQuery) WithOwner(opts ...func(*UserQuery)) *CarQuery {
  215. query := &UserQuery{config: cq.config}
  216. for _, opt := range opts {
  217. opt(query)
  218. }
  219. cq.withOwner = query
  220. return cq
  221. }
  222. // GroupBy used to group vertices by one or more fields/columns.
  223. // It is often used with aggregate functions, like: count, max, mean, min, sum.
  224. //
  225. // Example:
  226. //
  227. // var v []struct {
  228. // Model string `json:"model,omitempty"`
  229. // Count int `json:"count,omitempty"`
  230. // }
  231. //
  232. // client.Car.Query().
  233. // GroupBy(car.FieldModel).
  234. // Aggregate(ent.Count()).
  235. // Scan(ctx, &v)
  236. //
  237. func (cq *CarQuery) GroupBy(field string, fields ...string) *CarGroupBy {
  238. group := &CarGroupBy{config: cq.config}
  239. group.fields = append([]string{field}, fields...)
  240. group.sql = cq.sqlQuery()
  241. return group
  242. }
  243. // Select one or more fields from the given query.
  244. //
  245. // Example:
  246. //
  247. // var v []struct {
  248. // Model string `json:"model,omitempty"`
  249. // }
  250. //
  251. // client.Car.Query().
  252. // Select(car.FieldModel).
  253. // Scan(ctx, &v)
  254. //
  255. func (cq *CarQuery) Select(field string, fields ...string) *CarSelect {
  256. selector := &CarSelect{config: cq.config}
  257. selector.fields = append([]string{field}, fields...)
  258. selector.sql = cq.sqlQuery()
  259. return selector
  260. }
  261. func (cq *CarQuery) sqlAll(ctx context.Context) ([]*Car, error) {
  262. var (
  263. nodes = []*Car{}
  264. withFKs = cq.withFKs
  265. _spec = cq.querySpec()
  266. loadedTypes = [1]bool{
  267. cq.withOwner != nil,
  268. }
  269. )
  270. if cq.withOwner != nil {
  271. withFKs = true
  272. }
  273. if withFKs {
  274. _spec.Node.Columns = append(_spec.Node.Columns, car.ForeignKeys...)
  275. }
  276. _spec.ScanValues = func() []interface{} {
  277. node := &Car{config: cq.config}
  278. nodes = append(nodes, node)
  279. values := node.scanValues()
  280. if withFKs {
  281. values = append(values, node.fkValues()...)
  282. }
  283. return values
  284. }
  285. _spec.Assign = func(values ...interface{}) error {
  286. if len(nodes) == 0 {
  287. return fmt.Errorf("ent: Assign called without calling ScanValues")
  288. }
  289. node := nodes[len(nodes)-1]
  290. node.Edges.loadedTypes = loadedTypes
  291. return node.assignValues(values...)
  292. }
  293. if err := sqlgraph.QueryNodes(ctx, cq.driver, _spec); err != nil {
  294. return nil, err
  295. }
  296. if len(nodes) == 0 {
  297. return nodes, nil
  298. }
  299. if query := cq.withOwner; query != nil {
  300. ids := make([]int, 0, len(nodes))
  301. nodeids := make(map[int][]*Car)
  302. for i := range nodes {
  303. if fk := nodes[i].user_cars; fk != nil {
  304. ids = append(ids, *fk)
  305. nodeids[*fk] = append(nodeids[*fk], nodes[i])
  306. }
  307. }
  308. query.Where(user.IDIn(ids...))
  309. neighbors, err := query.All(ctx)
  310. if err != nil {
  311. return nil, err
  312. }
  313. for _, n := range neighbors {
  314. nodes, ok := nodeids[n.ID]
  315. if !ok {
  316. return nil, fmt.Errorf(`unexpected foreign-key "user_cars" returned %v`, n.ID)
  317. }
  318. for i := range nodes {
  319. nodes[i].Edges.Owner = n
  320. }
  321. }
  322. }
  323. return nodes, nil
  324. }
  325. func (cq *CarQuery) sqlCount(ctx context.Context) (int, error) {
  326. _spec := cq.querySpec()
  327. return sqlgraph.CountNodes(ctx, cq.driver, _spec)
  328. }
  329. func (cq *CarQuery) sqlExist(ctx context.Context) (bool, error) {
  330. n, err := cq.sqlCount(ctx)
  331. if err != nil {
  332. return false, fmt.Errorf("ent: check existence: %v", err)
  333. }
  334. return n > 0, nil
  335. }
  336. func (cq *CarQuery) querySpec() *sqlgraph.QuerySpec {
  337. _spec := &sqlgraph.QuerySpec{
  338. Node: &sqlgraph.NodeSpec{
  339. Table: car.Table,
  340. Columns: car.Columns,
  341. ID: &sqlgraph.FieldSpec{
  342. Type: field.TypeInt,
  343. Column: car.FieldID,
  344. },
  345. },
  346. From: cq.sql,
  347. Unique: true,
  348. }
  349. if ps := cq.predicates; len(ps) > 0 {
  350. _spec.Predicate = func(selector *sql.Selector) {
  351. for i := range ps {
  352. ps[i](selector)
  353. }
  354. }
  355. }
  356. if limit := cq.limit; limit != nil {
  357. _spec.Limit = *limit
  358. }
  359. if offset := cq.offset; offset != nil {
  360. _spec.Offset = *offset
  361. }
  362. if ps := cq.order; len(ps) > 0 {
  363. _spec.Order = func(selector *sql.Selector) {
  364. for i := range ps {
  365. ps[i](selector)
  366. }
  367. }
  368. }
  369. return _spec
  370. }
  371. func (cq *CarQuery) sqlQuery() *sql.Selector {
  372. builder := sql.Dialect(cq.driver.Dialect())
  373. t1 := builder.Table(car.Table)
  374. selector := builder.Select(t1.Columns(car.Columns...)...).From(t1)
  375. if cq.sql != nil {
  376. selector = cq.sql
  377. selector.Select(selector.Columns(car.Columns...)...)
  378. }
  379. for _, p := range cq.predicates {
  380. p(selector)
  381. }
  382. for _, p := range cq.order {
  383. p(selector)
  384. }
  385. if offset := cq.offset; offset != nil {
  386. // limit is mandatory for offset clause. We start
  387. // with default value, and override it below if needed.
  388. selector.Offset(*offset).Limit(math.MaxInt32)
  389. }
  390. if limit := cq.limit; limit != nil {
  391. selector.Limit(*limit)
  392. }
  393. return selector
  394. }
  395. // CarGroupBy is the builder for group-by Car entities.
  396. type CarGroupBy struct {
  397. config
  398. fields []string
  399. fns []Aggregate
  400. // intermediate query.
  401. sql *sql.Selector
  402. }
  403. // Aggregate adds the given aggregation functions to the group-by query.
  404. func (cgb *CarGroupBy) Aggregate(fns ...Aggregate) *CarGroupBy {
  405. cgb.fns = append(cgb.fns, fns...)
  406. return cgb
  407. }
  408. // Scan applies the group-by query and scan the result into the given value.
  409. func (cgb *CarGroupBy) Scan(ctx context.Context, v interface{}) error {
  410. return cgb.sqlScan(ctx, v)
  411. }
  412. // ScanX is like Scan, but panics if an error occurs.
  413. func (cgb *CarGroupBy) ScanX(ctx context.Context, v interface{}) {
  414. if err := cgb.Scan(ctx, v); err != nil {
  415. panic(err)
  416. }
  417. }
  418. // Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
  419. func (cgb *CarGroupBy) Strings(ctx context.Context) ([]string, error) {
  420. if len(cgb.fields) > 1 {
  421. return nil, errors.New("ent: CarGroupBy.Strings is not achievable when grouping more than 1 field")
  422. }
  423. var v []string
  424. if err := cgb.Scan(ctx, &v); err != nil {
  425. return nil, err
  426. }
  427. return v, nil
  428. }
  429. // StringsX is like Strings, but panics if an error occurs.
  430. func (cgb *CarGroupBy) StringsX(ctx context.Context) []string {
  431. v, err := cgb.Strings(ctx)
  432. if err != nil {
  433. panic(err)
  434. }
  435. return v
  436. }
  437. // Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
  438. func (cgb *CarGroupBy) Ints(ctx context.Context) ([]int, error) {
  439. if len(cgb.fields) > 1 {
  440. return nil, errors.New("ent: CarGroupBy.Ints is not achievable when grouping more than 1 field")
  441. }
  442. var v []int
  443. if err := cgb.Scan(ctx, &v); err != nil {
  444. return nil, err
  445. }
  446. return v, nil
  447. }
  448. // IntsX is like Ints, but panics if an error occurs.
  449. func (cgb *CarGroupBy) IntsX(ctx context.Context) []int {
  450. v, err := cgb.Ints(ctx)
  451. if err != nil {
  452. panic(err)
  453. }
  454. return v
  455. }
  456. // Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
  457. func (cgb *CarGroupBy) Float64s(ctx context.Context) ([]float64, error) {
  458. if len(cgb.fields) > 1 {
  459. return nil, errors.New("ent: CarGroupBy.Float64s is not achievable when grouping more than 1 field")
  460. }
  461. var v []float64
  462. if err := cgb.Scan(ctx, &v); err != nil {
  463. return nil, err
  464. }
  465. return v, nil
  466. }
  467. // Float64sX is like Float64s, but panics if an error occurs.
  468. func (cgb *CarGroupBy) Float64sX(ctx context.Context) []float64 {
  469. v, err := cgb.Float64s(ctx)
  470. if err != nil {
  471. panic(err)
  472. }
  473. return v
  474. }
  475. // Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
  476. func (cgb *CarGroupBy) Bools(ctx context.Context) ([]bool, error) {
  477. if len(cgb.fields) > 1 {
  478. return nil, errors.New("ent: CarGroupBy.Bools is not achievable when grouping more than 1 field")
  479. }
  480. var v []bool
  481. if err := cgb.Scan(ctx, &v); err != nil {
  482. return nil, err
  483. }
  484. return v, nil
  485. }
  486. // BoolsX is like Bools, but panics if an error occurs.
  487. func (cgb *CarGroupBy) BoolsX(ctx context.Context) []bool {
  488. v, err := cgb.Bools(ctx)
  489. if err != nil {
  490. panic(err)
  491. }
  492. return v
  493. }
  494. func (cgb *CarGroupBy) sqlScan(ctx context.Context, v interface{}) error {
  495. rows := &sql.Rows{}
  496. query, args := cgb.sqlQuery().Query()
  497. if err := cgb.driver.Query(ctx, query, args, rows); err != nil {
  498. return err
  499. }
  500. defer rows.Close()
  501. return sql.ScanSlice(rows, v)
  502. }
  503. func (cgb *CarGroupBy) sqlQuery() *sql.Selector {
  504. selector := cgb.sql
  505. columns := make([]string, 0, len(cgb.fields)+len(cgb.fns))
  506. columns = append(columns, cgb.fields...)
  507. for _, fn := range cgb.fns {
  508. columns = append(columns, fn(selector))
  509. }
  510. return selector.Select(columns...).GroupBy(cgb.fields...)
  511. }
  512. // CarSelect is the builder for select fields of Car entities.
  513. type CarSelect struct {
  514. config
  515. fields []string
  516. // intermediate queries.
  517. sql *sql.Selector
  518. }
  519. // Scan applies the selector query and scan the result into the given value.
  520. func (cs *CarSelect) Scan(ctx context.Context, v interface{}) error {
  521. return cs.sqlScan(ctx, v)
  522. }
  523. // ScanX is like Scan, but panics if an error occurs.
  524. func (cs *CarSelect) ScanX(ctx context.Context, v interface{}) {
  525. if err := cs.Scan(ctx, v); err != nil {
  526. panic(err)
  527. }
  528. }
  529. // Strings returns list of strings from selector. It is only allowed when selecting one field.
  530. func (cs *CarSelect) Strings(ctx context.Context) ([]string, error) {
  531. if len(cs.fields) > 1 {
  532. return nil, errors.New("ent: CarSelect.Strings is not achievable when selecting more than 1 field")
  533. }
  534. var v []string
  535. if err := cs.Scan(ctx, &v); err != nil {
  536. return nil, err
  537. }
  538. return v, nil
  539. }
  540. // StringsX is like Strings, but panics if an error occurs.
  541. func (cs *CarSelect) StringsX(ctx context.Context) []string {
  542. v, err := cs.Strings(ctx)
  543. if err != nil {
  544. panic(err)
  545. }
  546. return v
  547. }
  548. // Ints returns list of ints from selector. It is only allowed when selecting one field.
  549. func (cs *CarSelect) Ints(ctx context.Context) ([]int, error) {
  550. if len(cs.fields) > 1 {
  551. return nil, errors.New("ent: CarSelect.Ints is not achievable when selecting more than 1 field")
  552. }
  553. var v []int
  554. if err := cs.Scan(ctx, &v); err != nil {
  555. return nil, err
  556. }
  557. return v, nil
  558. }
  559. // IntsX is like Ints, but panics if an error occurs.
  560. func (cs *CarSelect) IntsX(ctx context.Context) []int {
  561. v, err := cs.Ints(ctx)
  562. if err != nil {
  563. panic(err)
  564. }
  565. return v
  566. }
  567. // Float64s returns list of float64s from selector. It is only allowed when selecting one field.
  568. func (cs *CarSelect) Float64s(ctx context.Context) ([]float64, error) {
  569. if len(cs.fields) > 1 {
  570. return nil, errors.New("ent: CarSelect.Float64s is not achievable when selecting more than 1 field")
  571. }
  572. var v []float64
  573. if err := cs.Scan(ctx, &v); err != nil {
  574. return nil, err
  575. }
  576. return v, nil
  577. }
  578. // Float64sX is like Float64s, but panics if an error occurs.
  579. func (cs *CarSelect) Float64sX(ctx context.Context) []float64 {
  580. v, err := cs.Float64s(ctx)
  581. if err != nil {
  582. panic(err)
  583. }
  584. return v
  585. }
  586. // Bools returns list of bools from selector. It is only allowed when selecting one field.
  587. func (cs *CarSelect) Bools(ctx context.Context) ([]bool, error) {
  588. if len(cs.fields) > 1 {
  589. return nil, errors.New("ent: CarSelect.Bools is not achievable when selecting more than 1 field")
  590. }
  591. var v []bool
  592. if err := cs.Scan(ctx, &v); err != nil {
  593. return nil, err
  594. }
  595. return v, nil
  596. }
  597. // BoolsX is like Bools, but panics if an error occurs.
  598. func (cs *CarSelect) BoolsX(ctx context.Context) []bool {
  599. v, err := cs.Bools(ctx)
  600. if err != nil {
  601. panic(err)
  602. }
  603. return v
  604. }
  605. func (cs *CarSelect) sqlScan(ctx context.Context, v interface{}) error {
  606. rows := &sql.Rows{}
  607. query, args := cs.sqlQuery().Query()
  608. if err := cs.driver.Query(ctx, query, args, rows); err != nil {
  609. return err
  610. }
  611. defer rows.Close()
  612. return sql.ScanSlice(rows, v)
  613. }
  614. func (cs *CarSelect) sqlQuery() sql.Querier {
  615. selector := cs.sql
  616. selector.Select(selector.Columns(cs.fields...)...)
  617. return selector
  618. }