Fix debug outputs for all templates
This commit is contained in:
parent
7ae9af702f
commit
8831e8a4b9
6 changed files with 28 additions and 31 deletions
|
@ -31,6 +31,7 @@ func {{$tableNameSingular}}Find(exec boil.Executor, {{$pkArgs}}, selectCols ...s
|
|||
sql := fmt.Sprintf(
|
||||
`select %s from "{{.Table.Name}}" where {{whereClause 1 .Table.PKey.Columns}}`, sel,
|
||||
)
|
||||
|
||||
q := boil.SQL(sql, {{$pkNames | join ", "}})
|
||||
boil.SetExecutor(q, exec)
|
||||
|
||||
|
|
|
@ -47,16 +47,17 @@ func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string
|
|||
query = fmt.Sprintf(`UPDATE {{.Table.Name}} SET %s WHERE %s`, strmangle.SetParamNames(wl), strmangle.WhereClause(len(wl)+1, {{$varNameSingular}}PrimaryKeyColumns))
|
||||
values = boil.GetStructValues(o, wl...)
|
||||
values = append(values, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, query)
|
||||
fmt.Fprintln(boil.DebugWriter, values)
|
||||
}
|
||||
|
||||
_, err = exec.Exec(query, values...)
|
||||
} else {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to update {{.Table.Name}}, could not build whitelist")
|
||||
}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, query)
|
||||
fmt.Fprintln(boil.DebugWriter, values)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to update {{.Table.Name}} row: %s", err)
|
||||
}
|
||||
|
@ -137,10 +138,12 @@ func (o {{$tableNameSingular}}Slice) UpdateAll(exec boil.Executor, cols M) error
|
|||
strmangle.Placeholders(len(o) * len({{$varNameSingular}}PrimaryKeyColumns), len(colNames)+1, len({{$varNameSingular}}PrimaryKeyColumns)),
|
||||
)
|
||||
|
||||
q := boil.SQL(sql, args...)
|
||||
boil.SetExecutor(q, exec)
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, sql)
|
||||
fmt.Fprintln(boil.DebugWriter, args...)
|
||||
}
|
||||
|
||||
_, err := boil.ExecQuery(q)
|
||||
_, err := exec.Exec(sql, args...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to update all in {{$varNameSingular}} slice: %s", err)
|
||||
}
|
||||
|
|
|
@ -34,17 +34,17 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, update bool, conflic
|
|||
return err
|
||||
}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, query)
|
||||
fmt.Fprintln(boil.DebugWriter, boil.GetStructValues(o, columns.whitelist...))
|
||||
}
|
||||
|
||||
if len(columns.returning) != 0 {
|
||||
err = exec.QueryRow(query, boil.GetStructValues(o, columns.whitelist...)...).Scan(boil.GetStructPointers(o, columns.returning...)...)
|
||||
} else {
|
||||
_, err = exec.Exec(query, {{.Table.Columns | columnNames | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})
|
||||
}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, query)
|
||||
fmt.Fprintln(boil.DebugWriter, boil.GetStructValues(o, columns.whitelist...))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to upsert for {{.Table.Name}}: %s", err)
|
||||
}
|
||||
|
|
|
@ -116,18 +116,15 @@ func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error {
|
|||
strmangle.Placeholders(len(o) * len({{$varNameSingular}}PrimaryKeyColumns), 1, len({{$varNameSingular}}PrimaryKeyColumns)),
|
||||
)
|
||||
|
||||
q := boil.SQL(sql, args...)
|
||||
boil.SetExecutor(q, exec)
|
||||
|
||||
_, err := boil.ExecQuery(q)
|
||||
if err != nil {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to delete all from {{$varNameSingular}} slice: %s", err)
|
||||
}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, sql)
|
||||
fmt.Fprintln(boil.DebugWriter, args)
|
||||
}
|
||||
|
||||
_, err := exec.Exec(sql, args...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("{{.PkgName}}: unable to delete all from {{$varNameSingular}} slice: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -86,10 +86,5 @@ func (o *{{$tableNameSingular}}Slice) ReloadAll(exec boil.Executor) error {
|
|||
|
||||
*o = {{$varNamePlural}}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, sql)
|
||||
fmt.Fprintln(boil.DebugWriter, args)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -7,6 +7,12 @@ func {{$tableNameSingular}}Exists(exec boil.Executor, {{$pkArgs}}) (bool, error)
|
|||
var exists bool
|
||||
|
||||
sql := `select exists(select 1 from "{{.Table.Name}}" where {{whereClause 1 .Table.PKey.Columns}} limit 1)`
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, sql)
|
||||
fmt.Fprintln(boil.DebugWriter, {{$pkNames | join ", "}})
|
||||
}
|
||||
|
||||
row := exec.QueryRow(
|
||||
sql,
|
||||
{{$pkNames | join ", "}},
|
||||
|
@ -17,11 +23,6 @@ func {{$tableNameSingular}}Exists(exec boil.Executor, {{$pkArgs}}) (bool, error)
|
|||
return false, fmt.Errorf("{{.PkgName}}: unable to check if {{.Table.Name}} exists: %v", err)
|
||||
}
|
||||
|
||||
if boil.DebugMode {
|
||||
fmt.Fprintln(boil.DebugWriter, sql)
|
||||
fmt.Fprintln(boil.DebugWriter, {{$pkNames | join ", "}})
|
||||
}
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue