Example #1
0
func (this *QueryBuilder) Super(translator db.Translator) {
	this.translator = translator
	this.columnPart = tk.NewJoiner(", ")
	this.fromPart = tk.NewJoiner(", ")
	this.joinPart = tk.NewStrBuffer()
	this.wherePart = tk.NewJoiner(" AND ")
	this.groupPart = tk.NewJoiner(", ")
	this.havingPart = tk.NewStrBuffer()
	this.orderPart = tk.NewJoiner(", ")
	this.unionPart = tk.NewStrBuffer()

}
Example #2
0
func (this *DmlBase) dumpParameters(params map[string]interface{}) string {
	str := tk.NewStrBuffer()
	for name, v := range params {
		if strings.HasSuffix(name, "$") {
			// secret
			str.Add(fmt.Sprintf("[%s=****]", name))
		} else if v != nil {
			typ := reflect.ValueOf(v)
			k := typ.Kind()
			if k == reflect.Slice || k == reflect.Array {
				str.Add(fmt.Sprintf("[%s=<BLOB>]", name))
			} else if k == reflect.Ptr {
				if typ.IsNil() {
					str.Add(fmt.Sprintf("[%s=NULL]", name))
				} else {
					str.Add(fmt.Sprintf("[%s=(*)%v]", name, typ.Elem().Interface()))
				}
			} else {
				str.Add(fmt.Sprintf("[%s=%v]", name, typ.Interface()))
			}
		} else {
			str.Add(fmt.Sprintf("[%s=NULL]", name))
		}
	}

	return str.String()
}
Example #3
0
func (this *Author) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add("}")
	return sb.String()
}
Example #4
0
func (this *Board) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Description: ", this.Description)
	sb.Add("}")
	return sb.String()
}
Example #5
0
func (this *Role) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Kind: ", this.Kind)
	sb.Add(", *UserId: ", *this.UserId)
	sb.Add("}")
	return sb.String()
}
Example #6
0
func (this *Consultant) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Project: ", this.Project)
	sb.Add("}")
	return sb.String()
}
Example #7
0
func (this *Status) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Code: ", this.Code)
	sb.Add(", Description: ", this.Description)
	sb.Add("}")
	return sb.String()
}
Example #8
0
func (this *Publisher) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Books: ", this.Books)
	sb.Add("}")
	return sb.String()
}
Example #9
0
func (this *Notification) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Email: ", this.Email)
	sb.Add(", TaskId: ", this.TaskId)
	sb.Add(", LaneId: ", this.LaneId)
	sb.Add("}")
	return sb.String()
}
Example #10
0
func (this *PublisherSales) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id)
	sb.Add(", Name: ", this.Name)
	sb.Add(", ThisYear: ", this.ThisYear)
	sb.Add(", PreviousYear: ", this.PreviousYear)
	sb.Add("}")
	return sb.String()
}
Example #11
0
func (this *Lane) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Position: ", this.Position)
	sb.Add(", *BoardId: ", *this.BoardId)
	sb.Add("}")
	return sb.String()
}
Example #12
0
func (this *User) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Username: "******", Password: "******"}")
	return sb.String()
}
Example #13
0
func rethrow(code string, cause error, sql string, params ...interface{}) error {
	causeMessage := cause.Error()

	msg := tk.NewStrBuffer(causeMessage, "\nSQL: ", sql, "\nParameters: ")
	if params != nil {
		msg.Add(fmt.Sprintf("%v", params))
	}

	return NewPersistenceFail(code, msg.String())
}
Example #14
0
func (this *GenericTranslator) GetSqlForInsert(insert *db.Insert) string {
	proc := this.CreateInsertProcessor(insert)

	str := tk.NewStrBuffer()
	// INSERT
	str.Add("INSERT INTO ", proc.TablePart(),
		"(", proc.ColumnPart(), ") VALUES(", proc.ValuePart(), ")")

	return str.String()
}
Example #15
0
func RolloverParameter(dmlType db.DmlType, tx db.Translator, parameters []db.Tokener, separator string) string {
	sb := tk.NewStrBuffer()
	for f, p := range parameters {
		if f > 0 && separator != "" {
			sb.Add(separator)
		}
		sb.Add(tx.Translate(dmlType, p))
	}
	return sb.String()
}
Example #16
0
func (this *Book) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", Price: ", this.Price)
	sb.Add(", Published: ", this.Published)
	sb.Add(", PublisherId: ", this.PublisherId)
	sb.Add(", Publisher: ", this.Publisher)
	sb.Add(", Title: ", this.Title)
	sb.Add("}")
	return sb.String()
}
Example #17
0
func (this *BookBin) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Hardcover: ")
	if len(this.Hardcover) == 0 {
		sb.Add("<nil>")
	} else {
		sb.Add("[]byte")
	}
	sb.Add("}")
	return sb.String()
}
Example #18
0
func (this *MySQL5Translator) PaginateSQL(query *db.Query, sql string) string {
	sb := tk.NewStrBuffer()
	if query.GetLimit() > 0 {
		sb.Add(sql, " LIMIT :", db.OFFSET_PARAM, ", :", db.LIMIT_PARAM)
		if query.GetSkip() >= 0 {
			query.SetParameter(db.OFFSET_PARAM, query.GetSkip())
		}
		query.SetParameter(db.LIMIT_PARAM, query.GetLimit())
		return sb.String()
	}

	return sql
}
Example #19
0
func (this *Project) String() string {
	sb := tk.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Name: ", this.Name)
	sb.Add(", ManagerId: ", this.ManagerId)
	sb.Add(", ManagerType: ", this.ManagerType)
	sb.Add(", Employee: ", this.Employee)
	sb.Add(", Consultant: ", this.Consultant)
	sb.Add(", StatusCod: ", this.StatusCod)
	sb.Add(", Status: ", this.Status)
	sb.Add("}")
	return sb.String()
}
Example #20
0
func (this *GenericTranslator) GetSqlForDelete(del *db.Delete) string {
	proc := this.CreateDeleteProcessor(del)

	sb := tk.NewStrBuffer()

	sb.Add("DELETE FROM ", proc.TablePart())
	where := proc.WherePart()
	// INNER JOINS NOT IMPLEMENTED
	if where != "" {
		sb.Add(" WHERE ", where)
	}

	return sb.String()
}
Example #21
0
// Parse the SQL statement and locate any placeholders or named parameters.
// Named parameters are substituted for a '?' placeholder
//
// param parsedSql
//            the parsed represenation of the SQL statement
// param paramSource
//            the source for named parameters
// return the SQL statement with substituted parameters
// see #parseSqlStatement
func SubstituteNamedParameters(parsedSql *ParsedSql, translator Translator) string {
	originalSql := parsedSql.String()
	actualSql := tk.NewStrBuffer()
	paramNames := parsedSql.Names
	lastIndex := 0
	for i, v := range paramNames {
		indexes := parsedSql.Indexes[i]
		startIndex := indexes[0]
		endIndex := indexes[1]
		actualSql.Add(originalSql[lastIndex:startIndex])
		actualSql.Add(translator.GetPlaceholder(i, v))
		lastIndex = endIndex
	}
	actualSql.Add(originalSql[lastIndex:])
	return actualSql.String()
}
Example #22
0
func (this *GenericTranslator) GetSqlForUpdate(update *db.Update) string {
	proc := this.CreateUpdateProcessor(update)

	// SET
	sel := tk.NewStrBuffer()
	sel.Add("UPDATE ", proc.TablePart())
	sel.Add(" SET ", proc.ColumnPart())
	// JOINS
	// sel.Add(proc.joinPart.String())
	// WHERE - conditions
	if update.GetCriteria() != nil {
		sel.Add(" WHERE ", proc.WherePart())
	}

	return sel.String()
}
Example #23
0
func (this *Task) String() string {
	sb := toolkit.NewStrBuffer()
	sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
	sb.Add(", Title: ", this.Title)
	sb.Add(", Detail: ", this.Detail)
	sb.Add(", HeadColor: ", this.HeadColor)
	sb.Add(", BodyColor: ", this.BodyColor)
	sb.Add(", Position: ", this.Position)
	sb.Add(", Reference: ", this.Reference)
	sb.Add(", Spent: ", this.Spent)
	sb.Add(", Remaining: ", this.Remaining)
	sb.Add(", *UserId: ", *this.UserId)
	sb.Add(", *LaneId: ", *this.LaneId)
	sb.Add("}")
	return sb.String()
}
Example #24
0
// INSERT
func (this *PostgreSQLTranslator) GetSqlForInsert(insert *db.Insert) string {
	// insert generated by super
	sql := this.GenericTranslator.GetSqlForInsert(insert)

	// only ONE numeric id is allowed
	// if no value was defined for the key, it is assumed an auto number,
	// otherwise is a guid (or something else)
	singleKeyColumn := insert.GetTable().GetSingleKeyColumn()
	if !insert.HasKeyValue && singleKeyColumn != nil {
		str := tk.NewStrBuffer()
		str.Add(sql, " RETURNING ", this.overrider.ColumnName(singleKeyColumn))
		sql = str.String()
	}

	return sql
}
Example #25
0
func (this *FirebirdSQLTranslator) PaginateSQL(query *db.Query, sql string) string {
	sb := tk.NewStrBuffer()
	if query.GetLimit() > 0 {
		sb.Add(sql, " ROWS ")
		if query.GetSkip() > 0 {
			sb.Add(":", db.OFFSET_PARAM, " TO ")
			query.SetParameter(db.OFFSET_PARAM, query.GetSkip()+1)
		}
		sb.Add(":", db.LIMIT_PARAM)
		query.SetParameter(db.LIMIT_PARAM, query.GetSkip()+query.GetLimit())

		return sb.String()
	}

	return sql
}
Example #26
0
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
}
Example #27
0
func (this *GenericTranslator) Init(overrider db.Translator) {
	this.overrider = overrider
	this.tokens = make(map[string]func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string)

	// Column
	this.RegisterTranslation(db.TOKEN_COLUMN, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		if col, ok := token.GetValue().(*db.Column); ok {
			sb := tk.NewStrBuffer()
			if token.GetTableAlias() != "" {
				sb.Add(token.GetTableAlias())
			} else {
				sb.Add(tx.TableName(col.GetTable()))
			}
			sb.Add(".", tx.ColumnName(col))
			return sb.String()
		}

		return ""
	})

	// Match
	this.RegisterTranslation(db.TOKEN_EQ, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		o := token.GetMembers()
		return tx.Translate(dmlType, o[0]) + " = " + tx.Translate(dmlType, o[1])
	})

	// Match
	this.RegisterTranslation(db.TOKEN_NULL, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		return "NULL"
	})

	// Val
	handle := func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		o := token.GetValue()
		if o != nil {
			if s, ok := o.(string); ok {
				return "'" + s + "'"
			} else {
				return fmt.Sprint(o)
			}
		}
		return "NULL"
	}
	this.RegisterTranslation(db.TOKEN_RAW, handle)
	this.RegisterTranslation(db.TOKEN_ASIS, handle)

	this.RegisterTranslation(db.TOKEN_IEQ, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("UPPER(%s) = UPPER(%s)", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	// Diferent
	this.RegisterTranslation(db.TOKEN_NEQ, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s <> %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	this.RegisterTranslation(db.TOKEN_RANGE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		field := tx.Translate(dmlType, m[0])
		var bottom string
		var top string
		if m[1] != nil {
			bottom = tx.Translate(dmlType, m[1])
		}
		if m[2] != nil {
			top = tx.Translate(dmlType, m[2])
		}

		if bottom != "" && top != "" {
			return fmt.Sprintf("%s >= %s AND %s <= %s", field, bottom, field, top)
		} else if bottom != "" {
			return fmt.Sprintf("%s >= %s", field, bottom)
		} else if top != "" {
			return fmt.Sprintf("%s <= %s", field, top)
		}
		panic("Invalid Range Token")

	})

	// ValueRange
	this.RegisterTranslation(db.TOKEN_VALUERANGE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		bottom := tx.Translate(dmlType, m[0])
		top := tx.Translate(dmlType, m[1])
		var value string
		if m[2] != nil {
			value = tx.Translate(dmlType, m[2])
		}

		if value != "" {
			return fmt.Sprintf(
				"(%1$s IS NULL AND %2$s IS NULL OR %1$s IS NULL AND %2$s <= %3$s OR %2$s IS NULL AND %1$s >= %3$s OR %1$s >= %3$s AND %2$s <= %3$s)",
				top, bottom, top, bottom, value, bottom, top, value, top, value, bottom, value,
			)
		}
		panic("Invalid ValueRange Token")
	})

	// boundedValueRange
	this.RegisterTranslation(db.TOKEN_BOUNDEDRANGE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		bottom := tx.Translate(dmlType, m[0])
		top := tx.Translate(dmlType, m[1])
		var value string
		if m[2] != nil {
			value = tx.Translate(dmlType, m[2])
		}

		if value != "" {
			return fmt.Sprintf("(%1$s >= %3$s AND %2$s <= %3$s)", top, value, bottom, value)
		}
		panic("Invalid BoundedRange Token")
	})

	// In
	this.RegisterTranslation(db.TOKEN_IN, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		var pattern string
		if token.GetOperator() == db.TOKEN_SUBQUERY {
			pattern = "%s%s IN %s"
		} else {
			pattern = "%s%s IN (%s)"
		}

		if c, ok := token.(*db.Criteria); ok {
			return fmt.Sprintf(
				pattern,
				this.isNot(c),
				tx.Translate(dmlType, m[0]),
				RolloverParameter(dmlType, tx, m[1:], ", "),
			)
		}
		return ""
	})

	// Or
	this.RegisterTranslation(db.TOKEN_OR, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("(%s)", RolloverParameter(dmlType, tx, m, " OR "))
	})

	// And
	this.RegisterTranslation(db.TOKEN_AND, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s", RolloverParameter(dmlType, tx, m, " AND "))
	})

	// Like
	this.RegisterTranslation(db.TOKEN_LIKE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		c := token.(*db.Criteria)
		m := token.GetMembers()
		return fmt.Sprintf("%s%s LIKE %s",
			tx.Translate(dmlType, m[0]), this.isNot(c), tx.Translate(dmlType, m[1]))
	})

	//	ILike
	this.RegisterTranslation(db.TOKEN_ILIKE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		c := token.(*db.Criteria)
		m := token.GetMembers()
		return fmt.Sprintf("UPPER(%s)%s LIKE UPPER(%s)",
			tx.Translate(dmlType, m[0]), this.isNot(c), tx.Translate(dmlType, m[1]))
	})

	// isNull
	this.RegisterTranslation(db.TOKEN_ISNULL, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		c := token.(*db.Criteria)
		m := token.GetMembers()
		return fmt.Sprintf("%s IS%s NULL", tx.Translate(dmlType, m[0]), this.isNot(c))
	})

	// Greater
	this.RegisterTranslation(db.TOKEN_GT, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s > %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	// Lesser
	this.RegisterTranslation(db.TOKEN_LT, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s < %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	// GreaterOrEqual
	this.RegisterTranslation(db.TOKEN_GTEQ, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s >= %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	// LesserOrEqual
	this.RegisterTranslation(db.TOKEN_LTEQ, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("%s <= %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	// FUNCTIONS
	// Param
	this.RegisterTranslation(db.TOKEN_PARAM, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		return fmt.Sprintf(":%s", token.GetValue())
	})

	// exists
	this.RegisterTranslation(db.TOKEN_EXISTS, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("EXISTS %s", tx.Translate(dmlType, m[0]))
	})

	this.RegisterTranslation(db.TOKEN_NOT, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("NOT %s", tx.Translate(dmlType, m[0]))
	})

	this.RegisterTranslation(db.TOKEN_ALIAS, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetValue()
		if m != nil {
			return fmt.Sprint(m)
		}
		return "NULL"
	})

	this.RegisterTranslation(db.TOKEN_SUM, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("SUM(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_MAX, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("MAX(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_MIN, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("MIN(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_UPPER, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("UPPER(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_LOWER, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("LOWER(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_ADD, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return RolloverParameter(dmlType, tx, m, " + ")
	})

	this.RegisterTranslation(db.TOKEN_MINUS, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return RolloverParameter(dmlType, tx, m, " - ")
	})

	this.RegisterTranslation(db.TOKEN_MULTIPLY, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return RolloverParameter(dmlType, tx, m, " * ")
	})

	this.RegisterTranslation(db.TOKEN_COUNT, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		return "COUNT(*)"
	})

	this.RegisterTranslation(db.TOKEN_COUNT_COLUMN, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("COUNT(%s)", tx.Translate(dmlType, m[0]))
	})

	this.RegisterTranslation(db.TOKEN_RTRIM, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("RTRIM(%s)", tx.Translate(dmlType, m[0]))
	})

	this.RegisterTranslation(db.TOKEN_SUBQUERY, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		v := token.GetValue()
		query := v.(*db.Query)
		return fmt.Sprintf("( %s )", this.GetSqlForQuery(query))
	})

	this.RegisterTranslation(db.TOKEN_COALESCE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("COALESCE(%s)", RolloverParameter(dmlType, tx, m, ", "))
	})

	this.RegisterTranslation(db.TOKEN_CASE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("CASE %s END", RolloverParameter(dmlType, tx, m, " "))
	})

	this.RegisterTranslation(db.TOKEN_CASE_WHEN, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("WHEN %s THEN %s", tx.Translate(dmlType, m[0]), tx.Translate(dmlType, m[1]))
	})

	this.RegisterTranslation(db.TOKEN_CASE_ELSE, func(dmlType db.DmlType, token db.Tokener, tx db.Translator) string {
		m := token.GetMembers()
		return fmt.Sprintf("ELSE %s", tx.Translate(dmlType, m[0]))
	})
}