Rename exec funcs to conform to sql stdlib

This commit is contained in:
Patrick O'brien 2016-09-15 02:14:30 +10:00
parent 702bb2095e
commit f6b4d3c6fd
7 changed files with 21 additions and 21 deletions

View file

@ -558,9 +558,9 @@ UpdateAll(models.M{"name": "John", "age": 23}) // Update all rows matching the b
DeleteAll() // Delete all rows matching the built query.
Exists() // Returns a bool indicating whether the row(s) for the built query exists.
Bind(&myObj) // Bind the results of a query to your own struct object.
ExecQuery() // Execute an SQL query that does not require any rows returned. Equivalent to `sql.Exec()`.
ExecQueryOne() // Execute an SQL query expected to return only a single row. Equivalent to `sql.QueryRow()`.
ExecQueryAll() // Execute an SQL query expected to return multiple rows. Equivalent to `sql.Query()`.
Exec() // Execute an SQL query that does not require any rows returned.
QueryRow() // Execute an SQL query expected to return only a single row.
Query() // Execute an SQL query expected to return multiple rows.
```
### Raw Query

View file

@ -96,8 +96,8 @@ func SQLG(query string, args ...interface{}) *Query {
return SQL(GetDB(), query, args...)
}
// ExecQuery executes a query that does not need a row returned
func (q *Query) ExecQuery() (sql.Result, error) {
// Exec executes a query that does not need a row returned
func (q *Query) Exec() (sql.Result, error) {
qs, args := buildQuery(q)
if DebugMode {
fmt.Fprintln(DebugWriter, qs)
@ -106,8 +106,8 @@ func (q *Query) ExecQuery() (sql.Result, error) {
return q.executor.Exec(qs, args...)
}
// ExecQueryOne executes the query for the One finisher and returns a row
func (q *Query) ExecQueryOne() *sql.Row {
// QueryRow executes the query for the One finisher and returns a row
func (q *Query) QueryRow() *sql.Row {
qs, args := buildQuery(q)
if DebugMode {
fmt.Fprintln(DebugWriter, qs)
@ -116,8 +116,8 @@ func (q *Query) ExecQueryOne() *sql.Row {
return q.executor.QueryRow(qs, args...)
}
// ExecQueryAll executes the query for the All finisher and returns multiple rows
func (q *Query) ExecQueryAll() (*sql.Rows, error) {
// Query executes the query for the All finisher and returns multiple rows
func (q *Query) Query() (*sql.Rows, error) {
qs, args := buildQuery(q)
if DebugMode {
fmt.Fprintln(DebugWriter, qs)
@ -126,10 +126,10 @@ func (q *Query) ExecQueryAll() (*sql.Rows, error) {
return q.executor.Query(qs, args...)
}
// ExecQueryP executes a query that does not need a row returned
// ExecP executes a query that does not need a row returned
// It will panic on error
func (q *Query) ExecQueryP() sql.Result {
res, err := q.ExecQuery()
func (q *Query) ExecP() sql.Result {
res, err := q.Exec()
if err != nil {
panic(WrapErr(err))
}
@ -137,10 +137,10 @@ func (q *Query) ExecQueryP() sql.Result {
return res
}
// ExecQueryAllP executes the query for the All finisher and returns multiple rows
// QueryP executes the query for the All finisher and returns multiple rows
// It will panic on error
func (q *Query) ExecQueryAllP() *sql.Rows {
rows, err := q.ExecQueryAll()
func (q *Query) QueryP() *sql.Rows {
rows, err := q.Query()
if err != nil {
panic(WrapErr(err))
}

View file

@ -100,7 +100,7 @@ func (q *Query) Bind(obj interface{}) error {
return err
}
rows, err := q.ExecQueryAll()
rows, err := q.Query()
if err != nil {
return errors.Wrap(err, "bind failed to execute query")
}

View file

@ -82,7 +82,7 @@ func (q {{$varNameSingular}}Query) Count() (int64, error) {
boil.SetSelect(q.Query, nil)
boil.SetCount(q.Query)
err := q.Query.ExecQueryOne().Scan(&count)
err := q.Query.QueryRow().Scan(&count)
if err != nil {
return 0, errors.Wrap(err, "{{.PkgName}}: failed to count {{.Table.Name}} rows")
}
@ -107,7 +107,7 @@ func (q {{$varNameSingular}}Query) Exists() (bool, error) {
boil.SetCount(q.Query)
boil.SetLimit(q.Query, 1)
err := q.Query.ExecQueryOne().Scan(&count)
err := q.Query.QueryRow().Scan(&count)
if err != nil {
return false, errors.Wrap(err, "{{.PkgName}}: failed to check if {{.Table.Name}} exists")
}

View file

@ -107,7 +107,7 @@ func (q {{$varNameSingular}}Query) UpdateAllP(cols M) {
func (q {{$varNameSingular}}Query) UpdateAll(cols M) error {
boil.SetUpdate(q.Query, cols)
_, err := q.Query.ExecQuery()
_, err := q.Query.Exec()
if err != nil {
return errors.Wrap(err, "{{.PkgName}}: unable to update all for {{.Table.Name}}")
}

View file

@ -38,8 +38,8 @@ func (o *{{$tableNameSingular}}) Upsert(exec boil.Executor, {{if ne .DriverName
var err error
var ret []string
whitelist, ret = strmangle.InsertColumnSet(
{{$varNameSingular}}ColumnsWithDefault,
{{$varNameSingular}}Columns,
{{$varNameSingular}}ColumnsWithDefault,
{{$varNameSingular}}ColumnsWithoutDefault,
boil.NonZeroDefaultSet({{$varNameSingular}}ColumnsWithDefault, o),
whitelist,

View file

@ -80,7 +80,7 @@ func (q {{$varNameSingular}}Query) DeleteAll() error {
boil.SetDelete(q.Query)
_, err := q.Query.ExecQuery()
_, err := q.Query.Exec()
if err != nil {
return errors.Wrap(err, "{{.PkgName}}: unable to delete all from {{.Table.Name}}")
}