Skip to content

Commit

Permalink
added SelectQuery.Info() helper to export the query field options
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Oct 30, 2022
1 parent 8402f60 commit 65afce6
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions select.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,42 @@ func (s *SelectQuery) Row(a ...interface{}) error {
func (s *SelectQuery) Column(a interface{}) error {
return s.Build().WithContext(s.ctx).Column(a)
}

// QueryInfo represents a debug/info struct with exported SelectQuery fields.
type QueryInfo struct {
Builder Builder
Selects []string
Distinct bool
SelectOption string
From []string
Where Expression
Join []JoinInfo
OrderBy []string
GroupBy []string
Having Expression
Union []UnionInfo
Limit int64
Offset int64
Params Params
}

// Info exports common SelectQuery fields allowing to inspect the
// current select query options.
func (s *SelectQuery) Info() *QueryInfo {
return &QueryInfo{
Builder: s.builder,
Selects: s.selects,
Distinct: s.distinct,
SelectOption: s.selectOption,
From: s.from,
Where: s.where,
Join: s.join,
OrderBy: s.orderBy,
GroupBy: s.groupBy,
Having: s.having,
Union: s.union,
Limit: s.limit,
Offset: s.offset,
Params: s.params,
}
}

0 comments on commit 65afce6

Please sign in to comment.