sq/libsq/ast/range.go
Neil O'Toole 9746f4c1a2
orderby() (#159)
* wip: orderby impl

* Tests passing (note: ast.checkASTIntegrity is disabled)

* ExprNode now rendered via renderSelectorNode

* linting

* CHAGELOG for v0.27.0
2023-03-25 19:20:53 -06:00

38 lines
750 B
Go

package ast
import "github.com/neilotoole/sq/libsq/ast/internal/slq"
// RowRangeNode models a range, effectively {OFFSET,LIMIT}.
type RowRangeNode struct {
baseNode
Offset int
Limit int
}
func newRowRangeNode(ctx *slq.RowRangeContext, offset, limit int) *RowRangeNode {
rr := &RowRangeNode{}
rr.ctx = ctx
rr.Offset = offset
rr.Limit = limit
return rr
}
func (rr *RowRangeNode) String() string {
return rr.Text()
}
func (rr *RowRangeNode) Range() (offset, limit int) {
offset = rr.Offset
limit = rr.Limit
return offset, limit
}
func (rr *RowRangeNode) SetParent(parent Node) error {
seg, ok := parent.(*SegmentNode)
if !ok {
return errorf("%T requires parent of type *%s", rr, typeSegmentNode)
}
rr.parent = seg
return nil
}