MCPcopy Index your code
hub / github.com/LissaGreense/GO4SQL / applyOffsetAndLimit

Method applyOffsetAndLimit

engine/engine.go:626–652  ·  view source on GitHub ↗
(command *ast.SelectCommand)

Source from the content-addressed store, hash-verified

624}
625
626func (table *Table) applyOffsetAndLimit(command *ast.SelectCommand) {
627 var offset = 0
628 var limitRaw = -1
629
630 if command.HasLimitCommand() {
631 limitRaw = command.LimitCommand.Count
632 }
633 if command.HasOffsetCommand() {
634 offset = command.OffsetCommand.Count
635 }
636
637 for _, column := range table.Columns {
638 var limit int
639
640 if limitRaw == -1 || limitRaw+offset > len(column.Values) {
641 limit = len(column.Values)
642 } else {
643 limit = limitRaw + offset
644 }
645
646 if offset > len(column.Values) || limit == 0 {
647 column.Values = make([]ValueInterface, 0)
648 } else {
649 column.Values = column.Values[offset:limit]
650 }
651 }
652}
653
654func xor(fulfilledFilters bool, negation bool) bool {
655 return (fulfilledFilters || negation) && !(fulfilledFilters && negation)

Callers 1

getSelectResponseMethod · 0.95

Calls 2

HasLimitCommandMethod · 0.80
HasOffsetCommandMethod · 0.80

Tested by

no test coverage detected