Skip to content

Commit

Permalink
feat: add Err method to query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jan 8, 2023
1 parent 07c7882 commit c722c90
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 0 deletions.
12 changes: 12 additions & 0 deletions query_column_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ func (q *AddColumnQuery) Model(model interface{}) *AddColumnQuery {
return q
}

func (q *AddColumnQuery) Err(err error) *AddColumnQuery {
q.setErr(err)
return q
}

func (q *AddColumnQuery) Apply(fn func(*AddColumnQuery) *AddColumnQuery) *AddColumnQuery {
if fn != nil {
return fn(q)
}
return q
}

//------------------------------------------------------------------------------

func (q *AddColumnQuery) Table(tables ...string) *AddColumnQuery {
Expand Down
12 changes: 12 additions & 0 deletions query_column_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ func (q *DropColumnQuery) Model(model interface{}) *DropColumnQuery {
return q
}

func (q *DropColumnQuery) Err(err error) *DropColumnQuery {
q.setErr(err)
return q
}

func (q *DropColumnQuery) Apply(fn func(*DropColumnQuery) *DropColumnQuery) *DropColumnQuery {
if fn != nil {
return fn(q)
}
return q
}

//------------------------------------------------------------------------------

func (q *DropColumnQuery) Table(tables ...string) *DropColumnQuery {
Expand Down
5 changes: 5 additions & 0 deletions query_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func (q *DeleteQuery) Model(model interface{}) *DeleteQuery {
return q
}

func (q *DeleteQuery) Err(err error) *DeleteQuery {
q.setErr(err)
return q
}

// Apply calls the fn passing the DeleteQuery as an argument.
func (q *DeleteQuery) Apply(fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery {
if fn != nil {
Expand Down
5 changes: 5 additions & 0 deletions query_index_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (q *CreateIndexQuery) Model(model interface{}) *CreateIndexQuery {
return q
}

func (q *CreateIndexQuery) Err(err error) *CreateIndexQuery {
q.setErr(err)
return q
}

func (q *CreateIndexQuery) Unique() *CreateIndexQuery {
q.unique = true
return q
Expand Down
5 changes: 5 additions & 0 deletions query_index_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func (q *DropIndexQuery) Model(model interface{}) *DropIndexQuery {
return q
}

func (q *DropIndexQuery) Err(err error) *DropIndexQuery {
q.setErr(err)
return q
}

//------------------------------------------------------------------------------

func (q *DropIndexQuery) Concurrently() *DropIndexQuery {
Expand Down
5 changes: 5 additions & 0 deletions query_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (q *InsertQuery) Model(model interface{}) *InsertQuery {
return q
}

func (q *InsertQuery) Err(err error) *InsertQuery {
q.setErr(err)
return q
}

// Apply calls the fn passing the SelectQuery as an argument.
func (q *InsertQuery) Apply(fn func(*InsertQuery) *InsertQuery) *InsertQuery {
if fn != nil {
Expand Down
5 changes: 5 additions & 0 deletions query_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func (q *MergeQuery) Model(model interface{}) *MergeQuery {
return q
}

func (q *MergeQuery) Err(err error) *MergeQuery {
q.setErr(err)
return q
}

// Apply calls the fn passing the MergeQuery as an argument.
func (q *MergeQuery) Apply(fn func(*MergeQuery) *MergeQuery) *MergeQuery {
if fn != nil {
Expand Down
5 changes: 5 additions & 0 deletions query_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (q *RawQuery) Conn(db IConn) *RawQuery {
return q
}

func (q *RawQuery) Err(err error) *RawQuery {
q.setErr(err)
return q
}

func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error {
if q.err != nil {
return q.err
Expand Down
5 changes: 5 additions & 0 deletions query_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func (q *SelectQuery) Model(model interface{}) *SelectQuery {
return q
}

func (q *SelectQuery) Err(err error) *SelectQuery {
q.setErr(err)
return q
}

// Apply calls the fn passing the SelectQuery as an argument.
func (q *SelectQuery) Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery {
if fn != nil {
Expand Down
5 changes: 5 additions & 0 deletions query_table_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (q *CreateTableQuery) Model(model interface{}) *CreateTableQuery {
return q
}

func (q *CreateTableQuery) Err(err error) *CreateTableQuery {
q.setErr(err)
return q
}

// ------------------------------------------------------------------------------

func (q *CreateTableQuery) Table(tables ...string) *CreateTableQuery {
Expand Down
5 changes: 5 additions & 0 deletions query_table_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func (q *DropTableQuery) Model(model interface{}) *DropTableQuery {
return q
}

func (q *DropTableQuery) Err(err error) *DropTableQuery {
q.setErr(err)
return q
}

//------------------------------------------------------------------------------

func (q *DropTableQuery) Table(tables ...string) *DropTableQuery {
Expand Down
5 changes: 5 additions & 0 deletions query_table_truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ func (q *TruncateTableQuery) Model(model interface{}) *TruncateTableQuery {
return q
}

func (q *TruncateTableQuery) Err(err error) *TruncateTableQuery {
q.setErr(err)
return q
}

//------------------------------------------------------------------------------

func (q *TruncateTableQuery) Table(tables ...string) *TruncateTableQuery {
Expand Down
5 changes: 5 additions & 0 deletions query_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (q *UpdateQuery) Model(model interface{}) *UpdateQuery {
return q
}

func (q *UpdateQuery) Err(err error) *UpdateQuery {
q.setErr(err)
return q
}

// Apply calls the fn passing the SelectQuery as an argument.
func (q *UpdateQuery) Apply(fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery {
if fn != nil {
Expand Down
5 changes: 5 additions & 0 deletions query_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func (q *ValuesQuery) Conn(db IConn) *ValuesQuery {
return q
}

func (q *ValuesQuery) Err(err error) *ValuesQuery {
q.setErr(err)
return q
}

func (q *ValuesQuery) Column(columns ...string) *ValuesQuery {
for _, column := range columns {
q.addColumn(schema.UnsafeIdent(column))
Expand Down

0 comments on commit c722c90

Please sign in to comment.