func (this *Query) ListSimple(closure func(), instances ...interface{}) error {
	return this.listClosure(func(rows *sql.Rows) error {
		err := rows.Scan(instances...)
		if err != nil {
			return err
		}
		closure()
		return nil
	})
}
======== RETRIVE ==============
List simple variables.
A closure is used to build the result list.
The types for scanning are supplied by the instances parameter.
No reflection is used.

ex:
roles = make([]string, 0)
var role string
q.ListSimple(func() {
roles = append(roles, role)
}, &role)
package db
import (
	"github.com/quintans/goSQL/dbx"
	tk "github.com/quintans/toolkit"
	coll "github.com/quintans/toolkit/collections"
	"database/sql"
	"fmt"
	"github.com/pkg/errors"
	"reflect"
	"time"
)
type Group struct {
	Position int
	Token    Tokener
}
const OFFSET_PARAM = "OFFSET_PARAM"
const LIMIT_PARAM = "LIMIT_PARAM"
type PostRetriever interface {
	PostRetrieve(store IDb)
}
type Query struct {
	DmlBase
	Columns       []Tokener
	subQuery      *Query
	subQueryAlias string
	distinct      bool
	orders []*Order
	unions []*Union
	groupBy   []int
	having    *Criteria
	skip      int64
	limit     int64
	lastToken Tokener
	lastOrder *Order
}
func NewQuery(db IDb, table *Table) *Query {
	this := new(Query)
	this.DmlBase.Super(db, table)
	return this
}
func (this *Query) Alias(alias string) *Query {
	this.alias(alias)
	return this
}
func NewQueryQuery(subquery *Query) *Query {
	return NewQueryQueryAs(subquery, "")
}
func NewQueryQueryAs(subquery *Query, subQueryAlias string) *Query {
	this := new(Query)
	this.Super(subquery.db, nil)
	this.subQuery = subquery
	this.subQueryAlias = subQueryAlias
	for k, v := range subquery.GetParameters() {
		this.SetParameter(k, v)
	}
	return this
}
func (this *Query) All() *Query {
	if this.table != nil {
		for it := this.table.columns.Enumerator(); it.HasNext(); {
			this.Column(it.Next().(*Column))
		}
	}
	return this
}
func (this *Query) Copy(other *Query) {
	this.table = other.table
	this.tableAlias = other.tableAlias
	if other.GetJoins() != nil {
		this.joins = make([]*Join, len(other.joins))
		copy(this.joins, other.joins)
	}
	if other.criteria != nil {
		this.criteria, _ = other.criteria.Clone().(*Criteria)
	}
	if this.parameters != nil {
		for k, v := range other.parameters {
			this.parameters[k] = v
		}
	}
	if other.subQuery != nil {
		q := other.subQuery
		this.subQuery = NewQuery(this.db, q.table)
		this.subQuery.Copy(q)
		this.subQueryAlias = other.subQueryAlias
	}
	this.distinct = other.distinct
	if other.Columns != nil {
		this.Columns = make([]Tokener, len(other.Columns))
		copy(this.Columns, other.Columns)
	}
	if other.orders != nil {
		this.orders = make([]*Order, len(other.orders))
		copy(this.orders, other.orders)
	}
	if other.unions != nil {
		this.unions = make([]*Union, len(other.unions))
		copy(this.unions, other.unions)
	}
	if other.groupBy != nil {
		this.groupBy = make([]int, len(other.groupBy))
		copy(this.groupBy, other.groupBy)
	}
	this.skip = other.skip
	this.limit = other.limit
	this.rawSQL = other.rawSQL
}
func (this *Query) GetSkip() int64 {
	return this.skip
}
func (this *Query) Skip(skip int64) *Query {
	if skip < 0 {
		this.skip = 0
	} else {
		this.skip = skip
	}
	return this
}
func (this *Query) GetLimit() int64 {
	return this.limit
}
func (this *Query) Limit(limit int64) *Query {
	if limit < 0 {
		this.limit = 0
	} else {
		this.limit = limit
	}
	return this
}
func (this *Query) GetSubQuery() *Query {
	return this.subQuery
}
func (this *Query) GetSubQueryAlias() string {
	return this.subQueryAlias
}
func (this *Query) Distinct() *Query {
	this.distinct = true
	this.rawSQL = nil
	return this
}
func (this *Query) IsDistinct() bool {
	return this.distinct
}
func (this *Query) ColumnsReset() {
	this.Columns = nil
}
func (this *Query) CountAll() *Query {
	return this.Column(Count(nil))
}
func (this *Query) Count(column interface{}) *Query {
	return this.Column(Count(column))
}
func (this *Query) Column(columns ...interface{}) *Query {
	for _, column := range columns {
		this.lastToken = tokenizeOne(column)
		this.replaceRaw(this.lastToken)
		this.lastToken.SetTableAlias(this.tableAlias)
		this.Columns = append(this.Columns, this.lastToken)
	}
	this.rawSQL = nil
	return this
}
func (this *Query) As(alias string) *Query {
	if this.lastToken != nil {
		this.lastToken.SetAlias(alias)
	} else if this.path != nil {
		this.path[len(this.path)-1].PreferredAlias = alias
	}
	this.rawSQL = nil
	return this
}
func (this *Query) Where(restriction ...*Criteria) *Query {
	if len(restriction) > 0 {
		this.DmlBase.where(restriction)
	}
	return this
}
func (this *Query) OrdersReset() {
	this.orders = nil
}
func (this *Query) OrderAs(columnHolder *ColumnHolder) *Query {
	this.lastOrder = NewOrder(columnHolder)
	this.orders = append(this.orders, this.lastOrder)
	this.rawSQL = nil
	return this
}
func (this *Query) Order(column *Column) *Query {
	return this.OrderAs(column.For(this.tableAlias))
}
func (this *Query) OrderOn(column *Column, associations ...*Association) *Query {
	pathElements := make([]*PathElement, len(associations))
	for k, association := range associations {
		pe := new(PathElement)
		pe.Base = association
		pe.Inner = false
		pathElements[k] = pe
	}
	return this.orderFor(column, pathElements...)
}
func (this *Query) orderFor(column *Column, pathElements ...*PathElement) *Query {
	var pes []*PathElement
	pes = pathElements
	common := DeepestCommonPath(this.cachedAssociation, pes)
	if len(common) == len(pes) {
		return this.OrderAs(column.For(pathElementAlias(common[len(common)-1])))
	}
	panic("The path specified in the order is not valid")
}
func (this *Query) OrderBy(column *Column) *Query {
	if this.path != nil {
		last := this.path[len(this.path)-1]
		if last.Orders == nil {
			last.Orders = make([]*Order, 0)
		}
		this.lastOrder = NewOrder(NewColumnHolder(column))
		last.Orders = append(last.Orders, this.lastOrder)
		return this
	} else if this.lastJoin != nil {
		return this.OrderAs(column.For(this.lastFkAlias))
	} else {
		return this.OrderAs(column.For(this.tableAlias))
	}
}
func (this *Query) OrderByAs(column string) *Query {
	this.lastOrder = NewOrderAs(column).Asc(true)
	this.orders = append(this.orders, this.lastOrder)
	this.rawSQL = nil
	return this
}
func (this *Query) Asc() *Query {
	return this.Dir(true)
}
func (this *Query) Desc() *Query {
	return this.Dir(false)
}
func (this *Query) Dir(asc bool) *Query {
	if this.lastOrder != nil {
		this.lastOrder.Asc(asc)
		this.rawSQL = nil
	}
	return this
}
func (this *Query) GetOrders() []*Order {
	return this.orders
}
func (this *Query) Inner(associations ...*Association) *Query {
	this.DmlBase.inner(true, associations...)
	this.lastToken = nil
	return this
}
func (this *Query) Outer(associations ...*Association) *Query {
	this.DmlBase.inner(false, associations...)
	this.lastToken = nil
	return this
}
func (this *Query) Fetch() *Query {
	if this.path != nil {
		for _, pe := range this.path {
			this.includeInPath(pe)  
		}
	}
	this.join(true)
	return this
}
func (this *Query) Join() *Query {
	this.join(false)
	return this
}
func (this *Query) join(fetch bool) {
	if this.path != nil {
		tokens := make([]Tokener, 0)
		for _, pe := range this.path {
			funs := pe.Columns
			if funs != nil {
				for _, fun := range funs {
					tokens = append(tokens, fun)
					if !fetch {
						fun.SetPseudoTableAlias(this.tableAlias)
					}
				}
			}
		}
		this.Columns = append(this.Columns, tokens...)
	}
	this.DmlBase.joinTo(this.path, fetch)
	if this.path != nil {
		for _, pe := range this.path {
			if pe.Orders != nil {
				for _, o := range pe.Orders {
					o.column.SetTableAlias(pathElementAlias(pe))
					this.orders = append(this.orders, o)
				}
			}
		}
	}
	this.path = nil
	this.rawSQL = nil
}
func pathElementAlias(pe *PathElement) string {
	derived := pe.Derived
	if derived.IsMany2Many() {
		return derived.ToM2M.GetAliasTo()
	} else {
		return derived.GetAliasTo()
	}
}
func (this *Query) Include(columns ...interface{}) *Query {
	lenPath := len(this.path)
	if lenPath > 0 {
		lastPath := this.path[lenPath-1]
		this.includeInPath(lastPath, columns...)
		this.rawSQL = nil
	} else {
		panic("There is no current join")
	}
	return this
}
func (this *Query) includeInPath(lastPath *PathElement, columns ...interface{}) {
	if len(columns) > 0 || len(lastPath.Columns) == 0 {
		if len(columns) == 0 {
			columns = lastPath.Base.GetTableTo().GetColumns().Elements()
		}
		if lastPath.Columns == nil {
			lastPath.Columns = make([]Tokener, 0)
		}
		for _, c := range columns {
			this.lastToken = tokenizeOne(c)
			lastPath.Columns = append(lastPath.Columns, this.lastToken)
		}
	}
}
func (this *Query) On(criteria ...*Criteria) *Query {
	if len(this.path) > 0 {
		var retriction *Criteria
		if len(criteria) > 1 {
			retriction = And(criteria...)
		} else if len(criteria) == 1 {
			retriction = criteria[0]
		} else {
			panic("nil or empty criterias was passed")
		}
		this.path[len(this.path)-1].Criteria = retriction
		this.rawSQL = nil
	} else {
		panic("There is no current join")
	}
	return this
}
func (this *Query) Union(query *Query) *Query {
	return this.unite(query, false)
}
func (this *Query) UnionAll(query *Query) *Query {
	return this.unite(query, true)
}
func (this *Query) unite(query *Query, all bool) *Query {
	for k, v := range query.GetParameters() {
		this.SetParameter(k, v)
	}
	this.unions = append(this.unions, &Union{query, all})
	this.rawSQL = nil
	return this
}
func (this *Query) GetUnions() []*Union {
	return this.unions
}
func (this *Query) GroupByUntil(untilPos int) *Query {
	this.groupBy = make([]int, untilPos)
	for i := 0; i < untilPos; i++ {
		this.groupBy[i] = i + 1
	}
	this.rawSQL = nil
	return this
}
func (this *Query) GroupByPos(pos ...int) *Query {
	this.groupBy = pos
	this.rawSQL = nil
	return this
}
func (this *Query) GetGroupBy() []int {
	return this.groupBy
}
func (this *Query) GetGroupByTokens() []Group {
	var groups []Group
	length := len(this.groupBy)
	if length > 0 {
		groups = make([]Group, length)
		for k, idx := range this.groupBy {
			groups[k].Position = idx - 1
			groups[k].Token = this.Columns[idx-1]
		}
	}
	return groups
}
func (this *Query) GroupBy(cols ...*Column) *Query {
	this.rawSQL = nil
	length := len(cols)
	if length == 0 {
		this.groupBy = nil
		return this
	}
	this.groupBy = make([]int, length)
	pos := 1
	for i := 0; i < length; i++ {
		for _, token := range this.Columns {
			if ch, ok := token.(*ColumnHolder); ok {
				if ch.GetColumn().Equals(cols[i]) {
					this.groupBy[i] = pos
					break
				}
			}
		}
		pos++
		if this.groupBy[i] == 0 {
			panic(fmt.Sprintf("Column alias '%' was not found", cols[i]))
		}
	}
	return this
}
func (this *Query) GroupByAs(aliases ...string) *Query {
	this.rawSQL = nil
	length := len(aliases)
	if length == 0 {
		this.groupBy = nil
		return this
	}
	this.groupBy = make([]int, length)
	pos := 1
	for i := 0; i < length; i++ {
		for _, token := range this.Columns {
			if aliases[i] == token.GetAlias() {
				this.groupBy[i] = pos
				break
			}
		}
		pos++
		if this.groupBy[i] == 0 {
			panic(fmt.Sprintf("Column alias '%' was not found", aliases[i]))
		}
	}
	return this
}
func (this *Query) Having(having ...*Criteria) *Query {
	if len(having) > 0 {
		this.having = And(having...)
		this.replaceAlias(this.having)
	}
	return this
}
func (this *Query) GetHaving() *Criteria {
	return this.having
}
func (this *Query) replaceAlias(token Tokener) {
	members := token.GetMembers()
	if token.GetOperator() == TOKEN_ALIAS {
		alias := token.GetValue().(string)
		for _, v := range this.Columns {
			if v.GetAlias() == alias {
				token.SetAlias(alias)
				token.SetMembers(v.GetMembers()...)
				token.SetOperator(v.GetOperator())
				token.SetTableAlias(v.GetTableAlias())
				token.SetValue(v.GetValue())
				break
			}
		}
		return
	} else {
		if members != nil {
			for _, t := range members {
				if t != nil {
					this.replaceAlias(t)
				}
			}
		}
	}
}