diff options
author | 2021-11-13 12:29:08 +0100 | |
---|---|---|
committer | 2021-11-13 12:29:08 +0100 | |
commit | 829a934d23ab221049b4d54926305d8d5d64c9ad (patch) | |
tree | f4e382b289c113d3ba8a3c7a183507a5609c46c0 /vendor/github.com/uptrace/bun/query_column_add.go | |
parent | smtp + email confirmation (#285) (diff) | |
download | gotosocial-829a934d23ab221049b4d54926305d8d5d64c9ad.tar.xz |
update dependencies (#296)
Diffstat (limited to 'vendor/github.com/uptrace/bun/query_column_add.go')
-rw-r--r-- | vendor/github.com/uptrace/bun/query_column_add.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/vendor/github.com/uptrace/bun/query_column_add.go b/vendor/github.com/uptrace/bun/query_column_add.go index 30d76e610..dff514904 100644 --- a/vendor/github.com/uptrace/bun/query_column_add.go +++ b/vendor/github.com/uptrace/bun/query_column_add.go @@ -11,6 +11,8 @@ import ( type AddColumnQuery struct { baseQuery + + ifNotExists bool } func NewAddColumnQuery(db *DB) *AddColumnQuery { @@ -59,6 +61,11 @@ func (q *AddColumnQuery) ColumnExpr(query string, args ...interface{}) *AddColum return q } +func (q *AddColumnQuery) IfNotExists() *AddColumnQuery { + q.ifNotExists = true + return q +} + //------------------------------------------------------------------------------ func (q *AddColumnQuery) Operation() string { @@ -82,6 +89,10 @@ func (q *AddColumnQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte b = append(b, " ADD "...) + if q.ifNotExists { + b = append(b, "IF NOT EXISTS "...) + } + b, err = q.columns[0].AppendQuery(fmter, b) if err != nil { return nil, err @@ -99,11 +110,5 @@ func (q *AddColumnQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Res } query := internal.String(queryBytes) - - res, err := q.exec(ctx, q, query) - if err != nil { - return nil, err - } - - return res, nil + return q.exec(ctx, q, query) } |