From db747cccfe34ae5f390f087d2cc69d553aac7ee3 Mon Sep 17 00:00:00 2001 From: Aaron L Date: Mon, 8 Aug 2016 11:05:08 -0700 Subject: [PATCH] Fix fallout of whereclause change --- templates/07_find.tpl | 2 +- templates/08_insert.tpl | 2 +- templates/11_delete.tpl | 2 +- templates/13_exists.tpl | 2 +- templates_test/exists.tpl | 2 +- templates_test/finishers.tpl | 2 +- templates_test/select.tpl | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/07_find.tpl b/templates/07_find.tpl index d8a4f4d..8ecc39c 100644 --- a/templates/07_find.tpl +++ b/templates/07_find.tpl @@ -29,7 +29,7 @@ func {{$tableNameSingular}}Find(exec boil.Executor, {{$pkArgs}}, selectCols ...s sel = strings.Join(strmangle.IdentQuoteSlice(selectCols), ",") } sql := fmt.Sprintf( - `select %s from "{{.Table.Name}}" where {{whereClause .Table.PKey.Columns 1}}`, sel, + `select %s from "{{.Table.Name}}" where {{whereClause 1 .Table.PKey.Columns}}`, sel, ) q := boil.SQL(sql, {{$pkNames | join ", "}}) boil.SetExecutor(q, exec) diff --git a/templates/08_insert.tpl b/templates/08_insert.tpl index 6f42361..480f55d 100644 --- a/templates/08_insert.tpl +++ b/templates/08_insert.tpl @@ -49,7 +49,7 @@ func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string lastId, err := result.lastInsertId() if err != nil || lastId == 0 { - sel := fmt.Sprintf(`SELECT %s FROM {{.Table.Name}} WHERE %s`, strings.Join(returnColumns, `","`), boil.WhereClause(wl)) + sel := fmt.Sprintf(`SELECT %s FROM {{.Table.Name}} WHERE %s`, strings.Join(returnColumns, `","`), strmangle.WhereClause(1, wl)) rows, err := exec.Query(sel, boil.GetStructValues(o, wl...)...) if err != nil { return fmt.Errorf("{{.PkgName}}: unable to insert into {{.Table.Name}}: %s", err) diff --git a/templates/11_delete.tpl b/templates/11_delete.tpl index f8b1820..c47081c 100644 --- a/templates/11_delete.tpl +++ b/templates/11_delete.tpl @@ -30,7 +30,7 @@ func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error { mods = append(mods, qm.From("{{.Table.Name}}"), - qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}), + qm.Where(`{{whereClause 1 .Table.PKey.Columns}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}), ) query := NewQuery(exec, mods...) diff --git a/templates/13_exists.tpl b/templates/13_exists.tpl index 4251ecc..828e275 100644 --- a/templates/13_exists.tpl +++ b/templates/13_exists.tpl @@ -7,7 +7,7 @@ func {{$tableNameSingular}}Exists(exec boil.Executor, {{$pkArgs}}) (bool, error) var exists bool row := exec.QueryRow( - `select exists(select 1 from "{{.Table.Name}}" where {{whereClause .Table.PKey.Columns 1}} limit 1)`, + `select exists(select 1 from "{{.Table.Name}}" where {{whereClause 1 .Table.PKey.Columns}} limit 1)`, {{$pkNames | join ", "}}, ) diff --git a/templates_test/exists.tpl b/templates_test/exists.tpl index d0ccfb3..6a5f0f8 100644 --- a/templates_test/exists.tpl +++ b/templates_test/exists.tpl @@ -24,7 +24,7 @@ func Test{{$tableNamePlural}}Exists(t *testing.T) { t.Errorf("Expected {{$tableNameSingular}}ExistsG to return true, but got false.") } - whereClause := strmangle.WhereClause({{$varNameSingular}}PrimaryKeyColumns, 1) + whereClause := strmangle.WhereClause(1, {{$varNameSingular}}PrimaryKeyColumns) e, err = {{$tableNamePlural}}G(qm.Where(whereClause, boil.GetStructValues(o, {{$varNameSingular}}PrimaryKeyColumns...)...)).Exists() if err != nil { t.Errorf("Unable to check if {{$tableNameSingular}} exists: %s", err) diff --git a/templates_test/finishers.tpl b/templates_test/finishers.tpl index eba4b64..07a8f9c 100644 --- a/templates_test/finishers.tpl +++ b/templates_test/finishers.tpl @@ -16,7 +16,7 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) { j := {{$tableNameSingular}}{} - err = {{$tableNamePlural}}G(qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})).Bind(&j) + err = {{$tableNamePlural}}G(qm.Where(`{{whereClause 1 .Table.PKey.Columns}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})).Bind(&j) if err != nil { t.Errorf("Unable to call Bind on {{$tableNameSingular}} single object: %s", err) } diff --git a/templates_test/select.tpl b/templates_test/select.tpl index dc22416..2581377 100644 --- a/templates_test/select.tpl +++ b/templates_test/select.tpl @@ -29,7 +29,7 @@ func Test{{$tableNamePlural}}Select(t *testing.T) { t.Errorf("Unable to insert item {{$tableNameSingular}}:\n%#v\nErr: %s", item, err) } - err = {{$tableNamePlural}}G(qm.Select({{$varNameSingular}}AutoIncrementColumns...), qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})).Bind(x) + err = {{$tableNamePlural}}G(qm.Select({{$varNameSingular}}AutoIncrementColumns...), qm.Where(`{{whereClause 1 .Table.PKey.Columns}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})).Bind(x) if err != nil { t.Errorf("Unable to select insert results with bind: %s", err) }