diff --git a/contracts/database/db/db.go b/contracts/database/db/db.go index fbc087cb1..18911918e 100644 --- a/contracts/database/db/db.go +++ b/contracts/database/db/db.go @@ -23,13 +23,14 @@ type Query interface { // Distinct() Query // dump // dumpRawSql + Delete() (*Result, error) // Each(callback func(rows []any) error) error Exists() (bool, error) Find(dest any, conds ...any) error First(dest any) error + // FirstOr FirstOrFail(dest any) error // decrement - Delete() (*Result, error) Get(dest any) error // GroupBy(column string) Query // GroupByRaw(query string, args ...any) Query @@ -51,12 +52,12 @@ type Query interface { OrderByDesc(column string) Query OrderByRaw(raw string) Query OrWhere(query any, args ...any) Query - OrWhereBetween(column string, args []any) Query + OrWhereBetween(column string, x, y any) Query OrWhereColumn(column1 string, column2 ...string) Query OrWhereIn(column string, args []any) Query OrWhereLike(column string, value string) Query OrWhereNot(query any, args ...any) Query - OrWhereNotBetween(column string, args []any) Query + OrWhereNotBetween(column string, x, y any) Query OrWhereNotIn(column string, args []any) Query OrWhereNotLike(column string, value string) Query OrWhereNotNull(column string) Query @@ -71,7 +72,7 @@ type Query interface { // take // ToSql // ToRawSql - Update(data any) (*Result, error) + Update(column any, value ...any) (*Result, error) // updateOrInsert // Value(column string, dest any) error // when diff --git a/contracts/database/orm/orm.go b/contracts/database/orm/orm.go index 81c83d675..e853f4cad 100644 --- a/contracts/database/orm/orm.go +++ b/contracts/database/orm/orm.go @@ -5,6 +5,7 @@ import ( "database/sql" "github.com/goravel/framework/contracts/database" + "github.com/goravel/framework/contracts/database/db" ) type Orm interface { @@ -52,13 +53,13 @@ type Query interface { // DB gets the underlying database connection. DB() (*sql.DB, error) // Delete deletes records matching given conditions, if the conditions are empty will delete all records. - Delete(value ...any) (*Result, error) + Delete(value ...any) (*db.Result, error) // Distinct specifies distinct fields to query. Distinct(args ...any) Query // Driver gets the driver for the query. Driver() string // Exec executes raw sql - Exec(sql string, values ...any) (*Result, error) + Exec(sql string, values ...any) (*db.Result, error) // Exists returns true if matching records exist; otherwise, it returns false. Exists(exists *bool) error // Find finds records that match given conditions. @@ -79,7 +80,7 @@ type Query interface { // return a new instance of the model initialized with those attributes. FirstOrNew(dest any, attributes any, values ...any) error // ForceDelete forces delete records matching given conditions. - ForceDelete(value ...any) (*Result, error) + ForceDelete(value ...any) (*db.Result, error) // Get retrieves all rows from the database. Get(dest any) error // Group specifies the group method on the query. @@ -114,14 +115,14 @@ type Query interface { OrderByDesc(column string) Query // OrWhere add an "or where" clause to the query. OrWhere(query any, args ...any) Query - // OrWhereIn adds an "or where column in" clause to the query. - OrWhereIn(column string, values []any) Query - // OrWhereNotIn adds an "or where column not in" clause to the query. - OrWhereNotIn(column string, values []any) Query // OrWhereBetween adds an "or where column between x and y" clause to the query. OrWhereBetween(column string, x, y any) Query + // OrWhereIn adds an "or where column in" clause to the query. + OrWhereIn(column string, values []any) Query // OrWhereNotBetween adds an "or where column not between x and y" clause to the query. OrWhereNotBetween(column string, x, y any) Query + // OrWhereNotIn adds an "or where column not in" clause to the query. + OrWhereNotIn(column string, values []any) Query // OrWhereNull adds a "or where column is null" clause to the query. OrWhereNull(column string) Query // Paginate the given query into a simple paginator. @@ -131,7 +132,7 @@ type Query interface { // Raw creates a raw query. Raw(sql string, values ...any) Query // Restore restores a soft deleted model. - Restore(model ...any) (*Result, error) + Restore(model ...any) (*db.Result, error) // Rollback rolls back the changes in a transaction. Rollback() error // Save updates value in a database @@ -155,7 +156,7 @@ type Query interface { // ToRawSql returns the query as a raw SQL string. ToRawSql() ToSql // Update updates records with the given column and values - Update(column any, value ...any) (*Result, error) + Update(column any, value ...any) (*db.Result, error) // UpdateOrCreate finds the first record that matches the given attributes // or create a new one with those attributes if none was found. UpdateOrCreate(dest any, attributes any, values any) error @@ -214,10 +215,6 @@ type Cursor interface { Scan(value any) error } -type Result struct { - RowsAffected int64 -} - type ToSql interface { Count() string Create(value any) string diff --git a/database/db/query.go b/database/db/query.go index d2d95aea5..4fd148e2a 100644 --- a/database/db/query.go +++ b/database/db/query.go @@ -95,10 +95,6 @@ func (r *Query) Exists() (bool, error) { } func (r *Query) Find(dest any, conds ...any) error { - if r.err != nil { - return r.err - } - var q db.Query if len(conds) > 2 { return errors.DatabaseInvalidArgumentNumber.Args(len(conds), "1 or 2") @@ -142,10 +138,6 @@ func (r *Query) First(dest any) error { } func (r *Query) FirstOrFail(dest any) error { - if r.err != nil { - return r.err - } - sql, args, err := r.buildSelect() if err != nil { return err @@ -257,13 +249,8 @@ func (r *Query) OrWhere(query any, args ...any) db.Query { return q } -func (r *Query) OrWhereBetween(column string, args []any) db.Query { - if len(args) != 2 { - r.err = errors.DatabaseInvalidArgumentNumber.Args(len(args), "2") - return r - } - - return r.OrWhere(sq.Expr(fmt.Sprintf("%s BETWEEN ? AND ?", column), args...)) +func (r *Query) OrWhereBetween(column string, x, y any) db.Query { + return r.OrWhere(sq.Expr(fmt.Sprintf("%s BETWEEN ? AND ?", column), x, y)) } func (r *Query) OrWhereColumn(column1 string, column2 ...string) db.Query { @@ -312,13 +299,8 @@ func (r *Query) OrWhereNot(query any, args ...any) db.Query { return r.OrWhere(sq.Expr(fmt.Sprintf("NOT (%s)", sql), args...)) } -func (r *Query) OrWhereNotBetween(column string, args []any) db.Query { - if len(args) != 2 { - r.err = errors.DatabaseInvalidArgumentNumber.Args(len(args), "2") - return r - } - - return r.OrWhere(sq.Expr(fmt.Sprintf("%s NOT BETWEEN ? AND ?", column), args...)) +func (r *Query) OrWhereNotBetween(column string, x, y any) db.Query { + return r.OrWhere(sq.Expr(fmt.Sprintf("%s NOT BETWEEN ? AND ?", column), x, y)) } func (r *Query) OrWhereNotIn(column string, args []any) db.Query { @@ -348,8 +330,17 @@ func (r *Query) Select(columns ...string) db.Query { return q } -func (r *Query) Update(data any) (*db.Result, error) { - mapData, err := convertToMap(data) +func (r *Query) Update(column any, value ...any) (*db.Result, error) { + columnStr, ok := column.(string) + if ok { + if len(value) != 1 { + return nil, errors.DatabaseInvalidArgumentNumber.Args(len(value), "1") + } + + return r.Update(map[string]any{columnStr: value[0]}) + } + + mapData, err := convertToMap(column) if err != nil { return nil, err } diff --git a/database/db/query_test.go b/database/db/query_test.go index 29b1d6cb5..7af3aedad 100644 --- a/database/db/query_test.go +++ b/database/db/query_test.go @@ -476,7 +476,7 @@ func (s *QueryTestSuite) TestOrWhereBetween() { s.mockDriver.EXPECT().Explain("SELECT * FROM users WHERE (name = ? OR age BETWEEN ? AND ?)", "John", 18, 30).Return("SELECT * FROM users WHERE (name = \"John\" OR age BETWEEN 18 AND 30)").Once() s.mockLogger.EXPECT().Trace(s.ctx, s.now, "SELECT * FROM users WHERE (name = \"John\" OR age BETWEEN 18 AND 30)", int64(0), nil).Return().Once() - err := s.query.Where("name", "John").OrWhereBetween("age", []any{18, 30}).Get(&users) + err := s.query.Where("name", "John").OrWhereBetween("age", 18, 30).Get(&users) s.Nil(err) } @@ -536,7 +536,7 @@ func (s *QueryTestSuite) TestOrWhereNotBetween() { s.mockDriver.EXPECT().Explain("SELECT * FROM users WHERE (name = ? OR age NOT BETWEEN ? AND ?)", "John", 18, 30).Return("SELECT * FROM users WHERE (name = \"John\" OR age NOT BETWEEN 18 AND 30)") s.mockLogger.EXPECT().Trace(s.ctx, s.now, "SELECT * FROM users WHERE (name = \"John\" OR age NOT BETWEEN 18 AND 30)", int64(0), nil).Return().Once() - err := s.query.Where("name", "John").OrWhereNotBetween("age", []any{18, 30}).Get(&users) + err := s.query.Where("name", "John").OrWhereNotBetween("age", 18, 30).Get(&users) s.Nil(err) } @@ -657,6 +657,27 @@ func (s *QueryTestSuite) TestUpdate() { mockResult.AssertExpectations(s.T()) }) + s.Run("single column", func() { + mockResult := &MockResult{} + mockResult.On("RowsAffected").Return(int64(1), nil) + + s.mockDriver.EXPECT().Config().Return(database.Config{}).Once() + s.mockBuilder.EXPECT().Exec("UPDATE users SET phone = ? WHERE name = ?", "1234567890", "John").Return(mockResult, nil).Once() + s.mockDriver.EXPECT().Explain("UPDATE users SET phone = ? WHERE name = ?", "1234567890", "John").Return("UPDATE users SET phone = \"1234567890\" WHERE name = \"John\"").Once() + s.mockLogger.EXPECT().Trace(s.ctx, s.now, "UPDATE users SET phone = \"1234567890\" WHERE name = \"John\"", int64(1), nil).Return().Once() + + result, err := s.query.Where("name", "John").Update("phone", "1234567890") + s.Nil(err) + s.Equal(int64(1), result.RowsAffected) + + mockResult.AssertExpectations(s.T()) + }) + + s.Run("failed to update single column with wrong number of arguments", func() { + _, err := s.query.Where("name", "John").Update("phone", "1234567890", "1234567890") + s.Equal(errors.DatabaseInvalidArgumentNumber.Args(2, "1"), err) + }) + s.Run("failed to exec", func() { user := TestUser{ Phone: "1234567890", diff --git a/database/gorm/query.go b/database/gorm/query.go index 1eb92da86..e9d66f74d 100644 --- a/database/gorm/query.go +++ b/database/gorm/query.go @@ -13,6 +13,7 @@ import ( "github.com/goravel/framework/contracts/config" contractsdatabase "github.com/goravel/framework/contracts/database" + contractsdb "github.com/goravel/framework/contracts/database/db" "github.com/goravel/framework/contracts/database/driver" contractsorm "github.com/goravel/framework/contracts/database/orm" "github.com/goravel/framework/contracts/log" @@ -165,7 +166,7 @@ func (r *Query) DB() (*sql.DB, error) { return r.instance.DB() } -func (r *Query) Delete(dest ...any) (*contractsorm.Result, error) { +func (r *Query) Delete(dest ...any) (*contractsdb.Result, error) { var ( realDest any err error @@ -194,7 +195,7 @@ func (r *Query) Delete(dest ...any) (*contractsorm.Result, error) { return nil, err } - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: res.RowsAffected, }, nil } @@ -210,11 +211,11 @@ func (r *Query) Driver() string { return r.dbConfig.Driver } -func (r *Query) Exec(sql string, values ...any) (*contractsorm.Result, error) { +func (r *Query) Exec(sql string, values ...any) (*contractsdb.Result, error) { query := r.buildConditions() result := query.instance.Exec(sql, values...) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } @@ -379,7 +380,7 @@ func (r *Query) FirstOrNew(dest any, attributes any, values ...any) error { return nil } -func (r *Query) ForceDelete(dest ...any) (*contractsorm.Result, error) { +func (r *Query) ForceDelete(dest ...any) (*contractsdb.Result, error) { var ( realDest any err error @@ -410,7 +411,7 @@ func (r *Query) ForceDelete(dest ...any) (*contractsorm.Result, error) { } } - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: res.RowsAffected, }, res.Error } @@ -635,7 +636,7 @@ func (r *Query) Raw(sql string, values ...any) contractsorm.Query { return r.new(r.instance.Raw(sql, values...)) } -func (r *Query) Restore(model ...any) (*contractsorm.Result, error) { +func (r *Query) Restore(model ...any) (*contractsdb.Result, error) { var ( realModel any err error @@ -679,7 +680,7 @@ func (r *Query) Restore(model ...any) (*contractsorm.Result, error) { return nil, err } - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: res.RowsAffected, }, res.Error } @@ -814,7 +815,7 @@ func (r *Query) ToRawSql() contractsorm.ToSql { return NewToSql(r.setConditions(r.conditions), r.log, true) } -func (r *Query) Update(column any, value ...any) (*contractsorm.Result, error) { +func (r *Query) Update(column any, value ...any) (*contractsdb.Result, error) { query := r.buildConditions() if _, ok := column.(string); !ok && len(value) > 0 { @@ -1514,7 +1515,7 @@ func (r *Query) updated(dest any) error { return r.event(contractsorm.EventUpdated, r.instance.Statement.Model, dest) } -func (r *Query) update(values any) (*contractsorm.Result, error) { +func (r *Query) update(values any) (*contractsdb.Result, error) { if len(r.instance.Statement.Selects) > 0 && len(r.instance.Statement.Omits) > 0 { return nil, errors.OrmQuerySelectAndOmitsConflict } @@ -1523,7 +1524,7 @@ func (r *Query) update(values any) (*contractsorm.Result, error) { for _, val := range r.instance.Statement.Selects { if val == Associations { result := r.instance.Session(&gormio.Session{FullSaveAssociations: true}).Updates(values) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } @@ -1531,7 +1532,7 @@ func (r *Query) update(values any) (*contractsorm.Result, error) { result := r.instance.Updates(values) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } @@ -1541,20 +1542,20 @@ func (r *Query) update(values any) (*contractsorm.Result, error) { if val == Associations { result := r.instance.Omit(Associations).Updates(values) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } } result := r.instance.Updates(values) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } result := r.instance.Omit(Associations).Updates(values) - return &contractsorm.Result{ + return &contractsdb.Result{ RowsAffected: result.RowsAffected, }, result.Error } diff --git a/mocks/database/db/Query.go b/mocks/database/db/Query.go index 22cd90481..4dc9ae023 100644 --- a/mocks/database/db/Query.go +++ b/mocks/database/db/Query.go @@ -444,17 +444,17 @@ func (_c *Query_OrWhere_Call) RunAndReturn(run func(interface{}, ...interface{}) return _c } -// OrWhereBetween provides a mock function with given fields: column, args -func (_m *Query) OrWhereBetween(column string, args []interface{}) db.Query { - ret := _m.Called(column, args) +// OrWhereBetween provides a mock function with given fields: column, x, y +func (_m *Query) OrWhereBetween(column string, x interface{}, y interface{}) db.Query { + ret := _m.Called(column, x, y) if len(ret) == 0 { panic("no return value specified for OrWhereBetween") } var r0 db.Query - if rf, ok := ret.Get(0).(func(string, []interface{}) db.Query); ok { - r0 = rf(column, args) + if rf, ok := ret.Get(0).(func(string, interface{}, interface{}) db.Query); ok { + r0 = rf(column, x, y) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(db.Query) @@ -471,14 +471,15 @@ type Query_OrWhereBetween_Call struct { // OrWhereBetween is a helper method to define mock.On call // - column string -// - args []interface{} -func (_e *Query_Expecter) OrWhereBetween(column interface{}, args interface{}) *Query_OrWhereBetween_Call { - return &Query_OrWhereBetween_Call{Call: _e.mock.On("OrWhereBetween", column, args)} +// - x interface{} +// - y interface{} +func (_e *Query_Expecter) OrWhereBetween(column interface{}, x interface{}, y interface{}) *Query_OrWhereBetween_Call { + return &Query_OrWhereBetween_Call{Call: _e.mock.On("OrWhereBetween", column, x, y)} } -func (_c *Query_OrWhereBetween_Call) Run(run func(column string, args []interface{})) *Query_OrWhereBetween_Call { +func (_c *Query_OrWhereBetween_Call) Run(run func(column string, x interface{}, y interface{})) *Query_OrWhereBetween_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].([]interface{})) + run(args[0].(string), args[1].(interface{}), args[2].(interface{})) }) return _c } @@ -488,7 +489,7 @@ func (_c *Query_OrWhereBetween_Call) Return(_a0 db.Query) *Query_OrWhereBetween_ return _c } -func (_c *Query_OrWhereBetween_Call) RunAndReturn(run func(string, []interface{}) db.Query) *Query_OrWhereBetween_Call { +func (_c *Query_OrWhereBetween_Call) RunAndReturn(run func(string, interface{}, interface{}) db.Query) *Query_OrWhereBetween_Call { _c.Call.Return(run) return _c } @@ -713,17 +714,17 @@ func (_c *Query_OrWhereNot_Call) RunAndReturn(run func(interface{}, ...interface return _c } -// OrWhereNotBetween provides a mock function with given fields: column, args -func (_m *Query) OrWhereNotBetween(column string, args []interface{}) db.Query { - ret := _m.Called(column, args) +// OrWhereNotBetween provides a mock function with given fields: column, x, y +func (_m *Query) OrWhereNotBetween(column string, x interface{}, y interface{}) db.Query { + ret := _m.Called(column, x, y) if len(ret) == 0 { panic("no return value specified for OrWhereNotBetween") } var r0 db.Query - if rf, ok := ret.Get(0).(func(string, []interface{}) db.Query); ok { - r0 = rf(column, args) + if rf, ok := ret.Get(0).(func(string, interface{}, interface{}) db.Query); ok { + r0 = rf(column, x, y) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(db.Query) @@ -740,14 +741,15 @@ type Query_OrWhereNotBetween_Call struct { // OrWhereNotBetween is a helper method to define mock.On call // - column string -// - args []interface{} -func (_e *Query_Expecter) OrWhereNotBetween(column interface{}, args interface{}) *Query_OrWhereNotBetween_Call { - return &Query_OrWhereNotBetween_Call{Call: _e.mock.On("OrWhereNotBetween", column, args)} +// - x interface{} +// - y interface{} +func (_e *Query_Expecter) OrWhereNotBetween(column interface{}, x interface{}, y interface{}) *Query_OrWhereNotBetween_Call { + return &Query_OrWhereNotBetween_Call{Call: _e.mock.On("OrWhereNotBetween", column, x, y)} } -func (_c *Query_OrWhereNotBetween_Call) Run(run func(column string, args []interface{})) *Query_OrWhereNotBetween_Call { +func (_c *Query_OrWhereNotBetween_Call) Run(run func(column string, x interface{}, y interface{})) *Query_OrWhereNotBetween_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].([]interface{})) + run(args[0].(string), args[1].(interface{}), args[2].(interface{})) }) return _c } @@ -757,7 +759,7 @@ func (_c *Query_OrWhereNotBetween_Call) Return(_a0 db.Query) *Query_OrWhereNotBe return _c } -func (_c *Query_OrWhereNotBetween_Call) RunAndReturn(run func(string, []interface{}) db.Query) *Query_OrWhereNotBetween_Call { +func (_c *Query_OrWhereNotBetween_Call) RunAndReturn(run func(string, interface{}, interface{}) db.Query) *Query_OrWhereNotBetween_Call { _c.Call.Return(run) return _c } @@ -1210,9 +1212,12 @@ func (_c *Query_Select_Call) RunAndReturn(run func(...string) db.Query) *Query_S return _c } -// Update provides a mock function with given fields: data -func (_m *Query) Update(data interface{}) (*db.Result, error) { - ret := _m.Called(data) +// Update provides a mock function with given fields: column, value +func (_m *Query) Update(column interface{}, value ...interface{}) (*db.Result, error) { + var _ca []interface{} + _ca = append(_ca, column) + _ca = append(_ca, value...) + ret := _m.Called(_ca...) if len(ret) == 0 { panic("no return value specified for Update") @@ -1220,19 +1225,19 @@ func (_m *Query) Update(data interface{}) (*db.Result, error) { var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(interface{}) (*db.Result, error)); ok { - return rf(data) + if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) (*db.Result, error)); ok { + return rf(column, value...) } - if rf, ok := ret.Get(0).(func(interface{}) *db.Result); ok { - r0 = rf(data) + if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) *db.Result); ok { + r0 = rf(column, value...) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*db.Result) } } - if rf, ok := ret.Get(1).(func(interface{}) error); ok { - r1 = rf(data) + if rf, ok := ret.Get(1).(func(interface{}, ...interface{}) error); ok { + r1 = rf(column, value...) } else { r1 = ret.Error(1) } @@ -1246,14 +1251,22 @@ type Query_Update_Call struct { } // Update is a helper method to define mock.On call -// - data interface{} -func (_e *Query_Expecter) Update(data interface{}) *Query_Update_Call { - return &Query_Update_Call{Call: _e.mock.On("Update", data)} +// - column interface{} +// - value ...interface{} +func (_e *Query_Expecter) Update(column interface{}, value ...interface{}) *Query_Update_Call { + return &Query_Update_Call{Call: _e.mock.On("Update", + append([]interface{}{column}, value...)...)} } -func (_c *Query_Update_Call) Run(run func(data interface{})) *Query_Update_Call { +func (_c *Query_Update_Call) Run(run func(column interface{}, value ...interface{})) *Query_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{})) + variadicArgs := make([]interface{}, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(interface{}) + } + } + run(args[0].(interface{}), variadicArgs...) }) return _c } @@ -1263,7 +1276,7 @@ func (_c *Query_Update_Call) Return(_a0 *db.Result, _a1 error) *Query_Update_Cal return _c } -func (_c *Query_Update_Call) RunAndReturn(run func(interface{}) (*db.Result, error)) *Query_Update_Call { +func (_c *Query_Update_Call) RunAndReturn(run func(interface{}, ...interface{}) (*db.Result, error)) *Query_Update_Call { _c.Call.Return(run) return _c } diff --git a/mocks/database/orm/Query.go b/mocks/database/orm/Query.go index 1360fb0a8..09ac028c1 100644 --- a/mocks/database/orm/Query.go +++ b/mocks/database/orm/Query.go @@ -3,10 +3,12 @@ package orm import ( - sql "database/sql" + db "github.com/goravel/framework/contracts/database/db" + mock "github.com/stretchr/testify/mock" orm "github.com/goravel/framework/contracts/database/orm" - mock "github.com/stretchr/testify/mock" + + sql "database/sql" ) // Query is an autogenerated mock type for the Query type @@ -379,7 +381,7 @@ func (_c *Query_DB_Call) RunAndReturn(run func() (*sql.DB, error)) *Query_DB_Cal } // Delete provides a mock function with given fields: value -func (_m *Query) Delete(value ...interface{}) (*orm.Result, error) { +func (_m *Query) Delete(value ...interface{}) (*db.Result, error) { var _ca []interface{} _ca = append(_ca, value...) ret := _m.Called(_ca...) @@ -388,16 +390,16 @@ func (_m *Query) Delete(value ...interface{}) (*orm.Result, error) { panic("no return value specified for Delete") } - var r0 *orm.Result + var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(...interface{}) (*orm.Result, error)); ok { + if rf, ok := ret.Get(0).(func(...interface{}) (*db.Result, error)); ok { return rf(value...) } - if rf, ok := ret.Get(0).(func(...interface{}) *orm.Result); ok { + if rf, ok := ret.Get(0).(func(...interface{}) *db.Result); ok { r0 = rf(value...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*orm.Result) + r0 = ret.Get(0).(*db.Result) } } @@ -435,12 +437,12 @@ func (_c *Query_Delete_Call) Run(run func(value ...interface{})) *Query_Delete_C return _c } -func (_c *Query_Delete_Call) Return(_a0 *orm.Result, _a1 error) *Query_Delete_Call { +func (_c *Query_Delete_Call) Return(_a0 *db.Result, _a1 error) *Query_Delete_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Query_Delete_Call) RunAndReturn(run func(...interface{}) (*orm.Result, error)) *Query_Delete_Call { +func (_c *Query_Delete_Call) RunAndReturn(run func(...interface{}) (*db.Result, error)) *Query_Delete_Call { _c.Call.Return(run) return _c } @@ -548,7 +550,7 @@ func (_c *Query_Driver_Call) RunAndReturn(run func() string) *Query_Driver_Call } // Exec provides a mock function with given fields: _a0, values -func (_m *Query) Exec(_a0 string, values ...interface{}) (*orm.Result, error) { +func (_m *Query) Exec(_a0 string, values ...interface{}) (*db.Result, error) { var _ca []interface{} _ca = append(_ca, _a0) _ca = append(_ca, values...) @@ -558,16 +560,16 @@ func (_m *Query) Exec(_a0 string, values ...interface{}) (*orm.Result, error) { panic("no return value specified for Exec") } - var r0 *orm.Result + var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(string, ...interface{}) (*orm.Result, error)); ok { + if rf, ok := ret.Get(0).(func(string, ...interface{}) (*db.Result, error)); ok { return rf(_a0, values...) } - if rf, ok := ret.Get(0).(func(string, ...interface{}) *orm.Result); ok { + if rf, ok := ret.Get(0).(func(string, ...interface{}) *db.Result); ok { r0 = rf(_a0, values...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*orm.Result) + r0 = ret.Get(0).(*db.Result) } } @@ -606,12 +608,12 @@ func (_c *Query_Exec_Call) Run(run func(_a0 string, values ...interface{})) *Que return _c } -func (_c *Query_Exec_Call) Return(_a0 *orm.Result, _a1 error) *Query_Exec_Call { +func (_c *Query_Exec_Call) Return(_a0 *db.Result, _a1 error) *Query_Exec_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Query_Exec_Call) RunAndReturn(run func(string, ...interface{}) (*orm.Result, error)) *Query_Exec_Call { +func (_c *Query_Exec_Call) RunAndReturn(run func(string, ...interface{}) (*db.Result, error)) *Query_Exec_Call { _c.Call.Return(run) return _c } @@ -1031,7 +1033,7 @@ func (_c *Query_FirstOrNew_Call) RunAndReturn(run func(interface{}, interface{}, } // ForceDelete provides a mock function with given fields: value -func (_m *Query) ForceDelete(value ...interface{}) (*orm.Result, error) { +func (_m *Query) ForceDelete(value ...interface{}) (*db.Result, error) { var _ca []interface{} _ca = append(_ca, value...) ret := _m.Called(_ca...) @@ -1040,16 +1042,16 @@ func (_m *Query) ForceDelete(value ...interface{}) (*orm.Result, error) { panic("no return value specified for ForceDelete") } - var r0 *orm.Result + var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(...interface{}) (*orm.Result, error)); ok { + if rf, ok := ret.Get(0).(func(...interface{}) (*db.Result, error)); ok { return rf(value...) } - if rf, ok := ret.Get(0).(func(...interface{}) *orm.Result); ok { + if rf, ok := ret.Get(0).(func(...interface{}) *db.Result); ok { r0 = rf(value...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*orm.Result) + r0 = ret.Get(0).(*db.Result) } } @@ -1087,12 +1089,12 @@ func (_c *Query_ForceDelete_Call) Run(run func(value ...interface{})) *Query_For return _c } -func (_c *Query_ForceDelete_Call) Return(_a0 *orm.Result, _a1 error) *Query_ForceDelete_Call { +func (_c *Query_ForceDelete_Call) Return(_a0 *db.Result, _a1 error) *Query_ForceDelete_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Query_ForceDelete_Call) RunAndReturn(run func(...interface{}) (*orm.Result, error)) *Query_ForceDelete_Call { +func (_c *Query_ForceDelete_Call) RunAndReturn(run func(...interface{}) (*db.Result, error)) *Query_ForceDelete_Call { _c.Call.Return(run) return _c } @@ -2389,7 +2391,7 @@ func (_c *Query_Raw_Call) RunAndReturn(run func(string, ...interface{}) orm.Quer } // Restore provides a mock function with given fields: model -func (_m *Query) Restore(model ...interface{}) (*orm.Result, error) { +func (_m *Query) Restore(model ...interface{}) (*db.Result, error) { var _ca []interface{} _ca = append(_ca, model...) ret := _m.Called(_ca...) @@ -2398,16 +2400,16 @@ func (_m *Query) Restore(model ...interface{}) (*orm.Result, error) { panic("no return value specified for Restore") } - var r0 *orm.Result + var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(...interface{}) (*orm.Result, error)); ok { + if rf, ok := ret.Get(0).(func(...interface{}) (*db.Result, error)); ok { return rf(model...) } - if rf, ok := ret.Get(0).(func(...interface{}) *orm.Result); ok { + if rf, ok := ret.Get(0).(func(...interface{}) *db.Result); ok { r0 = rf(model...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*orm.Result) + r0 = ret.Get(0).(*db.Result) } } @@ -2445,12 +2447,12 @@ func (_c *Query_Restore_Call) Run(run func(model ...interface{})) *Query_Restore return _c } -func (_c *Query_Restore_Call) Return(_a0 *orm.Result, _a1 error) *Query_Restore_Call { +func (_c *Query_Restore_Call) Return(_a0 *db.Result, _a1 error) *Query_Restore_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Query_Restore_Call) RunAndReturn(run func(...interface{}) (*orm.Result, error)) *Query_Restore_Call { +func (_c *Query_Restore_Call) RunAndReturn(run func(...interface{}) (*db.Result, error)) *Query_Restore_Call { _c.Call.Return(run) return _c } @@ -3006,7 +3008,7 @@ func (_c *Query_ToSql_Call) RunAndReturn(run func() orm.ToSql) *Query_ToSql_Call } // Update provides a mock function with given fields: column, value -func (_m *Query) Update(column interface{}, value ...interface{}) (*orm.Result, error) { +func (_m *Query) Update(column interface{}, value ...interface{}) (*db.Result, error) { var _ca []interface{} _ca = append(_ca, column) _ca = append(_ca, value...) @@ -3016,16 +3018,16 @@ func (_m *Query) Update(column interface{}, value ...interface{}) (*orm.Result, panic("no return value specified for Update") } - var r0 *orm.Result + var r0 *db.Result var r1 error - if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) (*orm.Result, error)); ok { + if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) (*db.Result, error)); ok { return rf(column, value...) } - if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) *orm.Result); ok { + if rf, ok := ret.Get(0).(func(interface{}, ...interface{}) *db.Result); ok { r0 = rf(column, value...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*orm.Result) + r0 = ret.Get(0).(*db.Result) } } @@ -3064,12 +3066,12 @@ func (_c *Query_Update_Call) Run(run func(column interface{}, value ...interface return _c } -func (_c *Query_Update_Call) Return(_a0 *orm.Result, _a1 error) *Query_Update_Call { +func (_c *Query_Update_Call) Return(_a0 *db.Result, _a1 error) *Query_Update_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Query_Update_Call) RunAndReturn(run func(interface{}, ...interface{}) (*orm.Result, error)) *Query_Update_Call { +func (_c *Query_Update_Call) RunAndReturn(run func(interface{}, ...interface{}) (*db.Result, error)) *Query_Update_Call { _c.Call.Return(run) return _c }