Пример #1
0
func NewWhere(where expr.Node, stmt *expr.SqlSelect) *Where {
	s := &Where{
		TaskBase: NewTaskBase("Where"),
		where:    where,
	}
	cols := make(map[string]*expr.Column)
	if len(stmt.From) == 1 {
		cols = stmt.UnAliasedColumns()
	} else {
		for _, from := range stmt.From {
			//u.Debugf("cols: %v", from.Columns)
			for _, col := range from.Columns {
				_, right, _ := col.LeftRight()
				if _, ok := cols[right]; !ok {
					//u.Debugf("col: %#v", col)
					cols[right] = col.Copy()
					cols[right].Index = len(cols) - 1
				} else {
					//u.Debugf("has col: %#v", col)
				}
			}
		}
	}

	//u.Debugf("found where columns: %d", len(cols))

	s.Handler = whereFilter(where, s, cols)
	return s
}
Пример #2
0
// Where-Filter
func NewWhereFilter(where expr.Node, stmt *expr.SqlSelect) *Where {
	s := &Where{
		TaskBase: NewTaskBase("WhereFilter"),
		where:    where,
	}
	cols := stmt.UnAliasedColumns()
	s.Handler = whereFilter(where, s, cols)
	return s
}