func (this *GenericTranslator) GetSqlForQuery(query *db.Query) string { proc := this.CreateQueryProcessor(query) // SELECT COLUNAS sel := tk.NewStrBuffer() sel.Add("SELECT ") if query.IsDistinct() { sel.Add("DISTINCT ") } sel.Add(proc.ColumnPart()) // FROM sel.Add(" FROM ", proc.FromPart()) // JOINS sel.Add(proc.JoinPart()) // WHERE - conditions if query.GetCriteria() != nil { sel.Add(" WHERE ", proc.WherePart()) } // GROUP BY if len(query.GetGroupBy()) != 0 { sel.Add(" GROUP BY ", proc.GroupPart()) } // HAVING if query.GetHaving() != nil { sel.Add(" HAVING ", proc.HavingPart()) } // UNION if len(query.GetUnions()) != 0 { sel.Add(proc.UnionPart()) } // ORDER if len(query.GetOrders()) != 0 { sel.Add(" ORDER BY ", proc.OrderPart()) } sql := this.overrider.PaginateSQL(query, sel.String()) return sql }
func (this *QueryBuilder) Where(query *db.Query) { criteria := query.GetCriteria() if criteria != nil { this.wherePart.Add(this.translator.Translate(db.QUERY, criteria)) } }