(ctx context.Context)
| 643 | } |
| 644 | |
| 645 | func (nq *NodeQuery) sqlQuery(ctx context.Context) *sql.Selector { |
| 646 | builder := sql.Dialect(nq.driver.Dialect()) |
| 647 | t1 := builder.Table(node.Table) |
| 648 | columns := nq.ctx.Fields |
| 649 | if len(columns) == 0 { |
| 650 | columns = node.Columns |
| 651 | } |
| 652 | selector := builder.Select(t1.Columns(columns...)...).From(t1) |
| 653 | if nq.sql != nil { |
| 654 | selector = nq.sql |
| 655 | selector.Select(selector.Columns(columns...)...) |
| 656 | } |
| 657 | if nq.ctx.Unique != nil && *nq.ctx.Unique { |
| 658 | selector.Distinct() |
| 659 | } |
| 660 | for _, m := range nq.modifiers { |
| 661 | m(selector) |
| 662 | } |
| 663 | for _, p := range nq.predicates { |
| 664 | p(selector) |
| 665 | } |
| 666 | for _, p := range nq.order { |
| 667 | p(selector) |
| 668 | } |
| 669 | if offset := nq.ctx.Offset; offset != nil { |
| 670 | // limit is mandatory for offset clause. We start |
| 671 | // with default value, and override it below if needed. |
| 672 | selector.Offset(*offset).Limit(math.MaxInt32) |
| 673 | } |
| 674 | if limit := nq.ctx.Limit; limit != nil { |
| 675 | selector.Limit(*limit) |
| 676 | } |
| 677 | return selector |
| 678 | } |
| 679 | |
| 680 | // ForUpdate locks the selected rows against concurrent updates, and prevent them from being |
| 681 | // updated, deleted or "selected ... for update" by other sessions, until the transaction is |
no test coverage detected