(sc *selectContext)
| 874 | } |
| 875 | |
| 876 | func buildSelect(sc *selectContext) (string, []interface{}, error) { |
| 877 | t := sc.schema.GetDbTableName() |
| 878 | |
| 879 | cols := MakeColumns(sc.schema, t, sc.fields, sc.join) |
| 880 | q := sq.Select(cols...).From(quote(t)) |
| 881 | q, err := AddFilterToQuery(sc.schema, q, sc.filter, sc.join) |
| 882 | if err != nil { |
| 883 | return "", nil, err |
| 884 | } |
| 885 | if sc.paginator != nil { |
| 886 | if sc.paginator.Key != "" { |
| 887 | property, err := sc.schema.GetPropertyByID(sc.paginator.Key) |
| 888 | if err == nil { |
| 889 | q = q.OrderBy(makeColumn(t, *property) + " " + sc.paginator.Order) |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | if sc.paginator.Limit != math.MaxUint64 { |
| 894 | q = q.Limit(uint64(sc.paginator.Limit)) |
| 895 | } |
| 896 | if sc.paginator.Offset > 0 { |
| 897 | q = q.Offset(sc.paginator.Offset) |
| 898 | } |
| 899 | } |
| 900 | if sc.join { |
| 901 | q = makeJoin(sc.schema, t, q) |
| 902 | } |
| 903 | return q.ToSql() |
| 904 | } |
| 905 | |
| 906 | func (tx *Transaction) executeSelect(ctx context.Context, sc *selectContext, sql string, args []interface{}) (list []*schema.Resource, total uint64, err error) { |
| 907 | tx.logQuery(sql, args...) |
no test coverage detected