From 3abac13aeb644da942649b4338d290cfbf2b1227 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Wed, 23 Aug 2017 16:37:33 -0400 Subject: [PATCH] export InterpolateParams --- templates/07_relationship_to_one_eager.tpl | 2 +- templates/08_relationship_one_to_one_eager.tpl | 2 +- templates/09_relationship_to_many_eager.tpl | 2 +- templates/10_relationship_to_one_setops.tpl | 2 +- templates/11_relationship_one_to_one_setops.tpl | 2 +- templates/12_relationship_to_many_setops.tpl | 8 ++++---- templates/15_insert.tpl | 4 ++-- templates/16_update.tpl | 4 ++-- templates/17_upsert.tpl | 4 ++-- templates/18_delete.tpl | 4 ++-- templates/20_exists.tpl | 2 +- templates/singleton/boil_queries.tpl | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/templates/07_relationship_to_one_eager.tpl b/templates/07_relationship_to_one_eager.tpl index 3bf42f4..28010fd 100644 --- a/templates/07_relationship_to_one_eager.tpl +++ b/templates/07_relationship_to_one_eager.tpl @@ -40,7 +40,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula ) if boil.DebugMode { - qStr, err := interpolateParams(query, args...) + qStr, err := InterpolateParams(query, args...) if err != nil { return err } diff --git a/templates/08_relationship_one_to_one_eager.tpl b/templates/08_relationship_one_to_one_eager.tpl index 1fbf5f7..261b30c 100644 --- a/templates/08_relationship_one_to_one_eager.tpl +++ b/templates/08_relationship_one_to_one_eager.tpl @@ -40,7 +40,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula ) if boil.DebugMode { - qStr, err := interpolateParams(query, args...) + qStr, err := InterpolateParams(query, args...) if err != nil { return err } diff --git a/templates/09_relationship_to_many_eager.tpl b/templates/09_relationship_to_many_eager.tpl index 3ec5bf9..8c4159b 100644 --- a/templates/09_relationship_to_many_eager.tpl +++ b/templates/09_relationship_to_many_eager.tpl @@ -49,7 +49,7 @@ func ({{$varNameSingular}}L) Load{{$txt.Function.Name}}(e boil.Executor, singula {{end -}} if boil.DebugMode { - qStr, err := interpolateParams(query, args...) + qStr, err := InterpolateParams(query, args...) if err != nil { return err } diff --git a/templates/10_relationship_to_one_setops.tpl b/templates/10_relationship_to_one_setops.tpl index b293b48..8362420 100644 --- a/templates/10_relationship_to_one_setops.tpl +++ b/templates/10_relationship_to_one_setops.tpl @@ -53,7 +53,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo values := []interface{}{related.{{$txt.ForeignTable.ColumnNameGo}}, o.{{$dot.Table.PKey.Columns | stringMap $dot.StringFuncs.titleCase | join ", o."}}{{"}"}} if boil.DebugMode { - qStr, err := interpolateParams(updateQuery, values...) + qStr, err := InterpolateParams(updateQuery, values...) if err != nil { return err } diff --git a/templates/11_relationship_one_to_one_setops.tpl b/templates/11_relationship_one_to_one_setops.tpl index d4583ca..7648e23 100644 --- a/templates/11_relationship_one_to_one_setops.tpl +++ b/templates/11_relationship_one_to_one_setops.tpl @@ -59,7 +59,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo values := []interface{}{o.{{$txt.LocalTable.ColumnNameGo}}, related.{{$foreignPKeyCols | stringMap $dot.StringFuncs.titleCase | join ", related."}}{{"}"}} if boil.DebugMode { - qStr, err := interpolateParams(updateQuery, values...) + qStr, err := InterpolateParams(updateQuery, values...) if err != nil { return err } diff --git a/templates/12_relationship_to_many_setops.tpl b/templates/12_relationship_to_many_setops.tpl index 35a4bd4..6794889 100644 --- a/templates/12_relationship_to_many_setops.tpl +++ b/templates/12_relationship_to_many_setops.tpl @@ -66,7 +66,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}(exec boil.Executo values := []interface{}{o.{{$txt.LocalTable.ColumnNameGo}}, rel.{{$foreignPKeyCols | stringMap $dot.StringFuncs.titleCase | join ", rel."}}{{"}"}} if boil.DebugMode { - qStr, err := interpolateParams(updateQuery, values...) + qStr, err := InterpolateParams(updateQuery, values...) if err != nil { return err } @@ -90,7 +90,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Add{{$txt.Function.Name}}(exec boil.Executo values := []interface{}{{"{"}}o.{{$txt.LocalTable.ColumnNameGo}}, rel.{{$txt.ForeignTable.ColumnNameGo}}} if boil.DebugMode { - qStr, err := interpolateParams(query, values...) + qStr, err := InterpolateParams(query, values...) if err != nil { return err } @@ -190,7 +190,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Set{{$txt.Function.Name}}(exec boil.Executo values := []interface{}{{"{"}}o.{{$txt.LocalTable.ColumnNameGo}}} {{end -}} if boil.DebugMode { - qStr, err := interpolateParams(query, values...) + qStr, err := InterpolateParams(query, values...) if err != nil { return err } @@ -269,7 +269,7 @@ func (o *{{$txt.LocalTable.NameGo}}) Remove{{$txt.Function.Name}}(exec boil.Exec } if boil.DebugMode { - qStr, err := interpolateParams(query, values...) + qStr, err := InterpolateParams(query, values...) if err != nil { return err } diff --git a/templates/15_insert.tpl b/templates/15_insert.tpl index 8cd30b9..00b6f5b 100644 --- a/templates/15_insert.tpl +++ b/templates/15_insert.tpl @@ -98,7 +98,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string vals := queries.ValuesFromMapping(value, cache.valueMapping) if boil.DebugMode { - qStr, err := interpolateParams(cache.query, vals...) + qStr, err := InterpolateParams(cache.query, vals...) if err != nil { return err } @@ -147,7 +147,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string } if boil.DebugMode { - qStr, err := interpolateParams(cache.retQuery, identifierCols...) + qStr, err := InterpolateParams(cache.retQuery, identifierCols...) if err != nil { return err } diff --git a/templates/16_update.tpl b/templates/16_update.tpl index 1ac460b..1f67234 100644 --- a/templates/16_update.tpl +++ b/templates/16_update.tpl @@ -78,7 +78,7 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping) if boil.DebugMode { - qStr, err := interpolateParams(cache.query, values...) + qStr, err := InterpolateParams(cache.query, values...) if err != nil { return err } @@ -173,7 +173,7 @@ func (o {{$tableNameSingular}}Slice) UpdateAll(exec boil.Executor, cols M) error strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), {{if .Dialect.IndexPlaceholders}}len(colNames)+1{{else}}0{{end}}, {{$varNameSingular}}PrimaryKeyColumns, len(o))) if boil.DebugMode { - qStr, err := interpolateParams(sql, args...) + qStr, err := InterpolateParams(sql, args...) if err != nil { return err } diff --git a/templates/17_upsert.tpl b/templates/17_upsert.tpl index 5cf6a14..6eef9fe 100644 --- a/templates/17_upsert.tpl +++ b/templates/17_upsert.tpl @@ -147,7 +147,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName } if boil.DebugMode { - qStr, err := interpolateParams(cache.query, vals...) + qStr, err := InterpolateParams(cache.query, vals...) if err != nil { return err } @@ -196,7 +196,7 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if eq .DriverName } if boil.DebugMode { - qStr, err := interpolateParams(cache.retQuery, identifierCols...) + qStr, err := InterpolateParams(cache.retQuery, identifierCols...) if err != nil { return err } diff --git a/templates/18_delete.tpl b/templates/18_delete.tpl index 20e819a..8c63e43 100644 --- a/templates/18_delete.tpl +++ b/templates/18_delete.tpl @@ -46,7 +46,7 @@ func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error { sql := "DELETE FROM {{$schemaTable}} WHERE {{if .Dialect.IndexPlaceholders}}{{whereClause .LQ .RQ 1 .Table.PKey.Columns}}{{else}}{{whereClause .LQ .RQ 0 .Table.PKey.Columns}}{{end}}" if boil.DebugMode { - qStr, err := interpolateParams(sql, args...) + qStr, err := InterpolateParams(sql, args...) if err != nil { return err } @@ -142,7 +142,7 @@ func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error { strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), {{if .Dialect.IndexPlaceholders}}1{{else}}0{{end}}, {{$varNameSingular}}PrimaryKeyColumns, len(o)) if boil.DebugMode { - qStr, err := interpolateParams(sql, args...) + qStr, err := InterpolateParams(sql, args...) if err != nil { return err } diff --git a/templates/20_exists.tpl b/templates/20_exists.tpl index 4c4031a..7d3dc3d 100644 --- a/templates/20_exists.tpl +++ b/templates/20_exists.tpl @@ -14,7 +14,7 @@ func {{$tableNameSingular}}Exists(exec boil.Executor, {{$pkArgs}}) (bool, error) {{- end}} if boil.DebugMode { - qStr, err := interpolateParams(sql, {{$pkNames | join ", "}}) + qStr, err := InterpolateParams(sql, {{$pkNames | join ", "}}) if err != nil { return false, err } diff --git a/templates/singleton/boil_queries.tpl b/templates/singleton/boil_queries.tpl index 11f103b..0d3c812 100644 --- a/templates/singleton/boil_queries.tpl +++ b/templates/singleton/boil_queries.tpl @@ -138,7 +138,7 @@ func checkMerge(tx *sql.Tx, foreignKeys []foreignKey) error { } // duplicated in queries/query.go -func interpolateParams(query string, args ...interface{}) (string, error) { +func InterpolateParams(query string, args ...interface{}) (string, error) { for i := 0; i < len(args); i++ { field := reflect.ValueOf(args[i])