diff options
Diffstat (limited to 'vendor/github.com/uptrace/bun')
-rw-r--r-- | vendor/github.com/uptrace/bun/CHANGELOG.md | 17 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/README.md | 23 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/db.go | 7 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/dialect/feature/feature.go | 4 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go | 3 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go | 3 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/package.json | 2 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/query_insert.go | 13 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/query_table_create.go | 12 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/query_update.go | 2 | ||||
-rw-r--r-- | vendor/github.com/uptrace/bun/version.go | 2 |
11 files changed, 69 insertions, 19 deletions
diff --git a/vendor/github.com/uptrace/bun/CHANGELOG.md b/vendor/github.com/uptrace/bun/CHANGELOG.md index f644ed6f5..afffdb2eb 100644 --- a/vendor/github.com/uptrace/bun/CHANGELOG.md +++ b/vendor/github.com/uptrace/bun/CHANGELOG.md @@ -1,3 +1,20 @@ +## [1.0.18](https://github.com/uptrace/bun/compare/v1.0.17...v1.0.18) (2021-11-24) + + +### Bug Fixes + +* use correct operation for UpdateQuery ([687a004](https://github.com/uptrace/bun/commit/687a004ef7ec6fe1ef06c394965dd2c2d822fc82)) + + +### Features + +* add pgdriver.Notify ([7ee443d](https://github.com/uptrace/bun/commit/7ee443d1b869d8ddc4746850f7425d0a9ccd012b)) +* CreateTableQuery.PartitionBy and CreateTableQuery.TableSpace ([cd3ab4d](https://github.com/uptrace/bun/commit/cd3ab4d8f3682f5a30b87c2ebc2d7e551d739078)) +* **pgdriver:** add CopyFrom and CopyTo ([0b97703](https://github.com/uptrace/bun/commit/0b977030b5c05f509e11d13550b5f99dfd62358d)) +* support InsertQuery.Ignore on PostgreSQL ([1aa9d14](https://github.com/uptrace/bun/commit/1aa9d149da8e46e63ff79192e394fde4d18d9b60)) + + + ## [1.0.17](https://github.com/uptrace/bun/compare/v1.0.16...v1.0.17) (2021-11-11) diff --git a/vendor/github.com/uptrace/bun/README.md b/vendor/github.com/uptrace/bun/README.md index 30ab3a2aa..0c27b9a37 100644 --- a/vendor/github.com/uptrace/bun/README.md +++ b/vendor/github.com/uptrace/bun/README.md @@ -9,7 +9,6 @@ [](https://github.com/uptrace/bun/actions) [](https://pkg.go.dev/github.com/uptrace/bun) [](https://bun.uptrace.dev/) -[](https://discord.gg/rWtp5Aj) **Status**: API freeze (stable release). Note that all sub-packages (mainly extra/\* packages) are not part of the API freeze and are developed independently. You can think of them as of 3rd party @@ -20,10 +19,10 @@ Main features are: - Works with [PostgreSQL](https://bun.uptrace.dev/guide/drivers.html#postgresql), [MySQL](https://bun.uptrace.dev/guide/drivers.html#mysql) (including MariaDB), [SQLite](https://bun.uptrace.dev/guide/drivers.html#sqlite). -- [Selecting](/example/basic/) into a map, struct, slice of maps/structs/vars. -- [Bulk inserts](https://bun.uptrace.dev/guide/queries.html#insert). -- [Bulk updates](https://bun.uptrace.dev/guide/queries.html#update) using common table expressions. -- [Bulk deletes](https://bun.uptrace.dev/guide/queries.html#delete). +- [Selecting](/example/basic/) into scalars, structs, maps, slices of maps/structs/scalars. +- [Bulk inserts](https://bun.uptrace.dev/guide/query-insert.html). +- [Bulk updates](https://bun.uptrace.dev/guide/query-update.html) using common table expressions. +- [Bulk deletes](https://bun.uptrace.dev/guide/query-delete.html). - [Fixtures](https://bun.uptrace.dev/guide/fixtures.html). - [Migrations](https://bun.uptrace.dev/guide/migrations.html). - [Soft deletes](https://bun.uptrace.dev/guide/soft-deletes.html). @@ -40,7 +39,8 @@ Resources: Projects using Bun: - [gotosocial](https://github.com/superseriousbusiness/gotosocial) - Golang fediverse server. -- [input-output-hk/cicero](https://github.com/input-output-hk/cicero) +- [qvalet](https://github.com/cmaster11/qvalet) listens for HTTP requests and executes commands on + demand. - [RealWorld app](https://github.com/go-bun/bun-realworld-app) <details> @@ -111,6 +111,7 @@ topRegions := db.NewSelect(). TableExpr("regional_sales"). Where("total_sales > (SELECT SUM(total_sales) / 10 FROM regional_sales)") +var items map[string]interface{} err := db.NewSelect(). With("regional_sales", regionalSales). With("top_regions", topRegions). @@ -122,7 +123,7 @@ err := db.NewSelect(). Where("region IN (SELECT region FROM top_regions)"). GroupExpr("region"). GroupExpr("product"). - Scan(ctx) + Scan(ctx, &items) ``` ```sql @@ -144,6 +145,8 @@ WHERE region IN (SELECT region FROM top_regions) GROUP BY region, product ``` +And scan results into scalars, structs, maps, slices of structs/maps/scalars. + ## Installation ```go @@ -212,13 +215,13 @@ db.RegisterModel((*User)(nil), (*Story)(nil)) // WithRecreateTables tells Bun to drop existing tables and create new ones. fixture := dbfixture.New(db, dbfixture.WithRecreateTables()) -// Load fixture.yaml which contains data for User and Story models. -if err := fixture.Load(ctx, os.DirFS("."), "fixture.yaml"); err != nil { +// Load fixture.yml which contains data for User and Story models. +if err := fixture.Load(ctx, os.DirFS("."), "fixture.yml"); err != nil { panic(err) } ``` -The `fixture.yaml` looks like this: +The `fixture.yml` looks like this: ```yaml - model: User diff --git a/vendor/github.com/uptrace/bun/db.go b/vendor/github.com/uptrace/bun/db.go index d42669493..c32474cef 100644 --- a/vendor/github.com/uptrace/bun/db.go +++ b/vendor/github.com/uptrace/bun/db.go @@ -178,6 +178,8 @@ func (db *DB) Table(typ reflect.Type) *schema.Table { return db.dialect.Tables().Get(typ) } +// RegisterModel registers models by name so they can be referenced in table relations +// and fixtures. func (db *DB) RegisterModel(models ...interface{}) { db.dialect.Tables().Register(models...) } @@ -201,6 +203,11 @@ func (db *DB) Formatter() schema.Formatter { return db.fmter } +// HasFeature uses feature package to report whether the underlying DBMS supports this feature. +func (db *DB) HasFeature(feat feature.Feature) bool { + return db.fmter.HasFeature(feat) +} + //------------------------------------------------------------------------------ func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error) { diff --git a/vendor/github.com/uptrace/bun/dialect/feature/feature.go b/vendor/github.com/uptrace/bun/dialect/feature/feature.go index 257e091fa..92d43ce21 100644 --- a/vendor/github.com/uptrace/bun/dialect/feature/feature.go +++ b/vendor/github.com/uptrace/bun/dialect/feature/feature.go @@ -17,5 +17,7 @@ const ( TableCascade TableIdentity TableTruncate - OnDuplicateKey + InsertOnConflict // INSERT ... ON CONFLICT + InsertOnDuplicateKey // INSERT ... ON DUPLICATE KEY + InsertIgnore // INSERT IGNORE ... ) diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go index aba82eac1..44e639141 100644 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/pgdialect/dialect.go @@ -31,7 +31,8 @@ func New() *Dialect { feature.DeleteTableAlias | feature.TableCascade | feature.TableIdentity | - feature.TableTruncate + feature.TableTruncate | + feature.InsertOnConflict return d } diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go index 74b278a5d..2536fe401 100644 --- a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go +++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/dialect.go @@ -23,7 +23,8 @@ func New() *Dialect { d.features = feature.CTE | feature.Returning | feature.InsertTableAlias | - feature.DeleteTableAlias + feature.DeleteTableAlias | + feature.InsertOnConflict return d } diff --git a/vendor/github.com/uptrace/bun/package.json b/vendor/github.com/uptrace/bun/package.json index f088afd3a..bb01b6cd1 100644 --- a/vendor/github.com/uptrace/bun/package.json +++ b/vendor/github.com/uptrace/bun/package.json @@ -1,6 +1,6 @@ { "name": "bun", - "version": "1.0.17", + "version": "1.0.18", "main": "index.js", "repository": "git@github.com:uptrace/bun.git", "author": "Vladimir Mihailenco <vladimir.webdev@gmail.com>", diff --git a/vendor/github.com/uptrace/bun/query_insert.go b/vendor/github.com/uptrace/bun/query_insert.go index 42ee49962..240077dd8 100644 --- a/vendor/github.com/uptrace/bun/query_insert.go +++ b/vendor/github.com/uptrace/bun/query_insert.go @@ -133,9 +133,16 @@ func (q *InsertQuery) hasReturning() bool { //------------------------------------------------------------------------------ -// Ignore generates an `INSERT IGNORE INTO` query (MySQL). +// Ignore generates different queries depending on the DBMS: +// - On MySQL, it generates `INSERT IGNORE INTO`. +// - On PostgreSQL, it generates `ON CONFLICT DO NOTHING`. func (q *InsertQuery) Ignore() *InsertQuery { - q.ignore = true + if q.db.fmter.HasFeature(feature.InsertOnConflict) { + return q.On("CONFLICT DO NOTHING") + } + if q.db.fmter.HasFeature(feature.InsertIgnore) { + q.ignore = true + } return q } @@ -421,7 +428,7 @@ func (q *InsertQuery) appendOn(fmter schema.Formatter, b []byte) (_ []byte, err } if len(q.set) > 0 { - if fmter.HasFeature(feature.OnDuplicateKey) { + if fmter.HasFeature(feature.InsertOnDuplicateKey) { b = append(b, ' ') } else { b = append(b, " SET "...) diff --git a/vendor/github.com/uptrace/bun/query_table_create.go b/vendor/github.com/uptrace/bun/query_table_create.go index 9d4fda104..66bb9c4a1 100644 --- a/vendor/github.com/uptrace/bun/query_table_create.go +++ b/vendor/github.com/uptrace/bun/query_table_create.go @@ -90,6 +90,18 @@ func (q *CreateTableQuery) ForeignKey(query string, args ...interface{}) *Create return q } +func (q *CreateTableQuery) PartitionBy(query string, args ...interface{}) *CreateTableQuery { + q.partitionBy = schema.SafeQuery(query, args) + return q +} + +func (q *CreateTableQuery) TableSpace(tablespace string) *CreateTableQuery { + q.tablespace = schema.UnsafeIdent(tablespace) + return q +} + +//------------------------------------------------------------------------------ + func (q *CreateTableQuery) Operation() string { return "CREATE TABLE" } diff --git a/vendor/github.com/uptrace/bun/query_update.go b/vendor/github.com/uptrace/bun/query_update.go index 2de4ace9a..23c722f56 100644 --- a/vendor/github.com/uptrace/bun/query_update.go +++ b/vendor/github.com/uptrace/bun/query_update.go @@ -166,7 +166,7 @@ func (q *UpdateQuery) hasReturning() bool { //------------------------------------------------------------------------------ func (q *UpdateQuery) Operation() string { - return "SELECT" + return "UPDATE" } func (q *UpdateQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) { diff --git a/vendor/github.com/uptrace/bun/version.go b/vendor/github.com/uptrace/bun/version.go index b5b744224..d2ebe5240 100644 --- a/vendor/github.com/uptrace/bun/version.go +++ b/vendor/github.com/uptrace/bun/version.go @@ -2,5 +2,5 @@ package bun // Version is the current release version. func Version() string { - return "1.0.17" + return "1.0.18" } |