QueryContext and ExecContext function parameters reorder.

This commit is contained in:
go-jet 2019-07-19 10:40:30 +02:00
parent b927769d5a
commit 733614d245
8 changed files with 14 additions and 14 deletions

View file

@ -89,7 +89,7 @@ func (d *deleteStatementImpl) Query(db execution.DB, destination interface{}) er
return query(d, db, destination) return query(d, db, destination)
} }
func (d *deleteStatementImpl) QueryContext(db execution.DB, context context.Context, destination interface{}) error { func (d *deleteStatementImpl) QueryContext(context context.Context, db execution.DB, destination interface{}) error {
return queryContext(context, d, db, destination) return queryContext(context, d, db, destination)
} }
@ -97,6 +97,6 @@ func (d *deleteStatementImpl) Exec(db execution.DB) (res sql.Result, err error)
return exec(d, db) return exec(d, db)
} }
func (d *deleteStatementImpl) ExecContext(db execution.DB, context context.Context) (res sql.Result, err error) { func (d *deleteStatementImpl) ExecContext(context context.Context, db execution.DB) (res sql.Result, err error) {
return execContext(d, db, context) return execContext(d, db, context)
} }

View file

@ -156,7 +156,7 @@ func (i *insertStatementImpl) Query(db execution.DB, destination interface{}) er
return query(i, db, destination) return query(i, db, destination)
} }
func (i *insertStatementImpl) QueryContext(db execution.DB, context context.Context, destination interface{}) error { func (i *insertStatementImpl) QueryContext(context context.Context, db execution.DB, destination interface{}) error {
return queryContext(context, i, db, destination) return queryContext(context, i, db, destination)
} }
@ -164,6 +164,6 @@ func (i *insertStatementImpl) Exec(db execution.DB) (res sql.Result, err error)
return exec(i, db) return exec(i, db)
} }
func (i *insertStatementImpl) ExecContext(db execution.DB, context context.Context) (res sql.Result, err error) { func (i *insertStatementImpl) ExecContext(context context.Context, db execution.DB) (res sql.Result, err error) {
return execContext(i, db, context) return execContext(i, db, context)
} }

View file

@ -83,7 +83,7 @@ var _ = Describe("Snaker", func() {
Expect(SnakeToCamel("id")).To(Equal("ID")) Expect(SnakeToCamel("id")).To(Equal("ID"))
}) })
It("sould work with initialism where only certain characters are uppercase", func() { It("should work with initialism where only certain characters are uppercase", func() {
Expect(SnakeToCamel("oauth_client")).To(Equal("OAuthClient")) Expect(SnakeToCamel("oauth_client")).To(Equal("OAuthClient"))
}) })
}) })

View file

@ -101,7 +101,7 @@ func (l *lockStatementImpl) Query(db execution.DB, destination interface{}) erro
return query(l, db, destination) return query(l, db, destination)
} }
func (l *lockStatementImpl) QueryContext(db execution.DB, context context.Context, destination interface{}) error { func (l *lockStatementImpl) QueryContext(context context.Context, db execution.DB, destination interface{}) error {
return queryContext(context, l, db, destination) return queryContext(context, l, db, destination)
} }
@ -109,6 +109,6 @@ func (l *lockStatementImpl) Exec(db execution.DB) (sql.Result, error) {
return exec(l, db) return exec(l, db)
} }
func (l *lockStatementImpl) ExecContext(db execution.DB, context context.Context) (res sql.Result, err error) { func (l *lockStatementImpl) ExecContext(context context.Context, db execution.DB) (res sql.Result, err error) {
return execContext(l, db, context) return execContext(l, db, context)
} }

View file

@ -283,7 +283,7 @@ func (s *selectStatementImpl) Query(db execution.DB, destination interface{}) er
return query(s.parent, db, destination) return query(s.parent, db, destination)
} }
func (s *selectStatementImpl) QueryContext(db execution.DB, context context.Context, destination interface{}) error { func (s *selectStatementImpl) QueryContext(context context.Context, db execution.DB, destination interface{}) error {
return queryContext(context, s.parent, db, destination) return queryContext(context, s.parent, db, destination)
} }
@ -291,7 +291,7 @@ func (s *selectStatementImpl) Exec(db execution.DB) (res sql.Result, err error)
return exec(s.parent, db) return exec(s.parent, db)
} }
func (s *selectStatementImpl) ExecContext(db execution.DB, context context.Context) (res sql.Result, err error) { func (s *selectStatementImpl) ExecContext(context context.Context, db execution.DB) (res sql.Result, err error) {
return execContext(s.parent, db, context) return execContext(s.parent, db, context)
} }

View file

@ -23,12 +23,12 @@ type Statement interface {
Query(db execution.DB, destination interface{}) error Query(db execution.DB, destination interface{}) error
// QueryContext executes statement with a context over database connection db and stores row result in destination. // QueryContext executes statement with a context over database connection db and stores row result in destination.
// Destination can be of arbitrary structure // Destination can be of arbitrary structure
QueryContext(db execution.DB, context context.Context, destination interface{}) error QueryContext(context context.Context, db execution.DB, destination interface{}) error
//Exec executes statement over db connection without returning any rows. //Exec executes statement over db connection without returning any rows.
Exec(db execution.DB) (sql.Result, error) Exec(db execution.DB) (sql.Result, error)
//Exec executes statement with context over db connection without returning any rows. //Exec executes statement with context over db connection without returning any rows.
ExecContext(db execution.DB, context context.Context) (sql.Result, error) ExecContext(context context.Context, db execution.DB) (sql.Result, error)
} }
func debugSql(statement Statement) (string, error) { func debugSql(statement Statement) (string, error) {

View file

@ -273,7 +273,7 @@ func TestExecWithContext(t *testing.T) {
CROSS_JOIN(Track). CROSS_JOIN(Track).
CROSS_JOIN(InvoiceLine). CROSS_JOIN(InvoiceLine).
SELECT(Album.AllColumns, Track.AllColumns, InvoiceLine.AllColumns). SELECT(Album.AllColumns, Track.AllColumns, InvoiceLine.AllColumns).
ExecContext(db, ctx) ExecContext(ctx, db)
assert.Error(t, err, "pq: canceling statement due to user request") assert.Error(t, err, "pq: canceling statement due to user request")
} }

View file

@ -135,7 +135,7 @@ func (u *updateStatementImpl) Query(db execution.DB, destination interface{}) er
return query(u, db, destination) return query(u, db, destination)
} }
func (u *updateStatementImpl) QueryContext(db execution.DB, context context.Context, destination interface{}) error { func (u *updateStatementImpl) QueryContext(context context.Context, db execution.DB, destination interface{}) error {
return queryContext(context, u, db, destination) return queryContext(context, u, db, destination)
} }
@ -143,6 +143,6 @@ func (u *updateStatementImpl) Exec(db execution.DB) (res sql.Result, err error)
return exec(u, db) return exec(u, db)
} }
func (u *updateStatementImpl) ExecContext(db execution.DB, context context.Context) (res sql.Result, err error) { func (u *updateStatementImpl) ExecContext(context context.Context, db execution.DB) (res sql.Result, err error) {
return execContext(u, db, context) return execContext(u, db, context)
} }