Fix fallout of whereclause change
This commit is contained in:
parent
b1d1b30724
commit
db747cccfe
7 changed files with 7 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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...)
|
||||
|
|
|
@ -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 ", "}},
|
||||
)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue