本文整理汇总了Golang中github.com/quintans/toolkit.NewStrBuffer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStrBuffer函数的具体用法?Golang NewStrBuffer怎么用?Golang NewStrBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStrBuffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Super
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:12,代码来源:GenericTranslator.go
示例2: dumpParameters
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:27,代码来源:DmlBase.go
示例3: String
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:7,代码来源:entities.go
示例4: String
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()
}
开发者ID:quintans,项目名称:taskboard,代码行数:8,代码来源:0_Board.go
示例5: String
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()
}
开发者ID:quintans,项目名称:taskboard,代码行数:8,代码来源:0_Role.go
示例6: String
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()
}
开发者ID:quintans,项目名称:taskboard,代码行数:9,代码来源:0_Notification.go
示例7: String
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()
}
开发者ID:quintans,项目名称:taskboard,代码行数:9,代码来源:0_Lane.go
示例8: String
func (this *User) String() string {
sb := toolkit.NewStrBuffer()
sb.Add("{Id: ", this.Id, ", Version: ", this.Version)
sb.Add(", Name: ", this.Name)
sb.Add(", Username: ", this.Username)
sb.Add(", Password: ", this.Password)
sb.Add("}")
return sb.String()
}
开发者ID:quintans,项目名称:taskboard,代码行数:9,代码来源:0_User.go
示例9: rethrow
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())
}
开发者ID:quintans,项目名称:goSQL,代码行数:10,代码来源:SimpleDBA.go
示例10: GetSqlForInsert
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:10,代码来源:GenericTranslator.go
示例11: RolloverParameter
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:10,代码来源:GenericTranslator.go
示例12: PaginateSQL
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
}
开发者ID:quintans,项目名称:goSQL,代码行数:13,代码来源:MySQL5Translator.go
示例13: GetSqlForDelete
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:14,代码来源:GenericTranslator.go
示例14: SubstituteNamedParameters
// 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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:25,代码来源:NamedParameterUtils.go
示例15: GetSqlForUpdate
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()
}
开发者ID:quintans,项目名称:goSQL,代码行数:16,代码来源:GenericTranslator.go
示例16: String
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()
}
开发者ID:quintans,项目名称:taskboard,代码行数:16,代码来源:0_Task.go
示例17: GetSqlForInsert
// 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
}
开发者ID:quintans,项目名称:goSQL,代码行数:17,代码来源:PostgreSQLTranslator.go
示例18: PaginateSQL
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
}
开发者ID:quintans,项目名称:goSQL,代码行数:16,代码来源:FirebirdSQLTranslator.go
示例19: GetSqlForQuery
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
}
开发者ID:quintans,项目名称:goSQL,代码行数:39,代码来源:GenericTranslator.go
示例20: Init
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
//.........这里部分代码省略.........
开发者ID:quintans,项目名称:goSQL,代码行数:101,代码来源:GenericTranslator.go
注:本文中的github.com/quintans/toolkit.NewStrBuffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论