mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 18:52:24 -05:00
Upstep Go dependencies (#340)
* Upstep Go dependencies * tiny linter fix * Tidy
This commit is contained in:
parent
5506a5ecbe
commit
67ac8db190
160 changed files with 248601 additions and 232400 deletions
9
vendor/github.com/uptrace/bun/CHANGELOG.md
generated
vendored
9
vendor/github.com/uptrace/bun/CHANGELOG.md
generated
vendored
|
|
@ -1,3 +1,12 @@
|
|||
## [1.0.19](https://github.com/uptrace/bun/compare/v1.0.18...v1.0.19) (2021-11-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support for column:name to specify column name ([e37b460](https://github.com/uptrace/bun/commit/e37b4602823babc8221970e086cfed90c6ad4cf4))
|
||||
|
||||
|
||||
|
||||
## [1.0.18](https://github.com/uptrace/bun/compare/v1.0.17...v1.0.18) (2021-11-24)
|
||||
|
||||
|
||||
|
|
|
|||
149
vendor/github.com/uptrace/bun/README.md
generated
vendored
149
vendor/github.com/uptrace/bun/README.md
generated
vendored
|
|
@ -29,10 +29,10 @@ Main features are:
|
|||
|
||||
Resources:
|
||||
|
||||
- [Discussions](https://github.com/uptrace/bun/discussions).
|
||||
- [Newsletter](https://blog.uptrace.dev/pages/newsletter.html) to get latest updates.
|
||||
- [**Get started**](https://bun.uptrace.dev/guide/getting-started.html)
|
||||
- [Examples](https://github.com/uptrace/bun/tree/master/example)
|
||||
- [Documentation](https://bun.uptrace.dev/)
|
||||
- [Discussions](https://github.com/uptrace/bun/discussions)
|
||||
- [Newsletter](https://blog.uptrace.dev/pages/newsletter.html) to get latest updates.
|
||||
- [Reference](https://pkg.go.dev/github.com/uptrace/bun)
|
||||
- [Starter kit](https://github.com/go-bun/bun-starter-kit)
|
||||
|
||||
|
|
@ -156,147 +156,8 @@ go get github.com/uptrace/bun
|
|||
You also need to install a database/sql driver and the corresponding Bun
|
||||
[dialect](https://bun.uptrace.dev/guide/drivers.html).
|
||||
|
||||
## Quickstart
|
||||
|
||||
First you need to create a `sql.DB`. Here we are using the
|
||||
[sqliteshim](https://pkg.go.dev/github.com/uptrace/bun/driver/sqliteshim) driver which chooses
|
||||
between [modernc.org/sqlite](https://modernc.org/sqlite/) and
|
||||
[mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) depending on your platform.
|
||||
|
||||
```go
|
||||
import "github.com/uptrace/bun/driver/sqliteshim"
|
||||
|
||||
sqldb, err := sql.Open(sqliteshim.ShimName, "file::memory:?cache=shared")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
And then create a `bun.DB` on top of it using the corresponding SQLite
|
||||
[dialect](https://bun.uptrace.dev/guide/drivers.html) that comes with Bun:
|
||||
|
||||
```go
|
||||
import (
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/dialect/sqlitedialect"
|
||||
)
|
||||
|
||||
db := bun.NewDB(sqldb, sqlitedialect.New())
|
||||
```
|
||||
|
||||
Now you are ready to issue some queries:
|
||||
|
||||
```go
|
||||
type User struct {
|
||||
ID int64
|
||||
Name string
|
||||
}
|
||||
|
||||
user := new(User)
|
||||
err := db.NewSelect().
|
||||
Model(user).
|
||||
Where("name != ?", "").
|
||||
OrderExpr("id ASC").
|
||||
Limit(1).
|
||||
Scan(ctx)
|
||||
```
|
||||
|
||||
## Basic example
|
||||
|
||||
To provide initial data for our [example](/example/basic/), we will use Bun
|
||||
[fixtures](https://bun.uptrace.dev/guide/fixtures.html):
|
||||
|
||||
```go
|
||||
import "github.com/uptrace/bun/dbfixture"
|
||||
|
||||
// Register models for the fixture.
|
||||
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.yml which contains data for User and Story models.
|
||||
if err := fixture.Load(ctx, os.DirFS("."), "fixture.yml"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
The `fixture.yml` looks like this:
|
||||
|
||||
```yaml
|
||||
- model: User
|
||||
rows:
|
||||
- _id: admin
|
||||
name: admin
|
||||
emails: ['admin1@admin', 'admin2@admin']
|
||||
- _id: root
|
||||
name: root
|
||||
emails: ['root1@root', 'root2@root']
|
||||
|
||||
- model: Story
|
||||
rows:
|
||||
- title: Cool story
|
||||
author_id: '{{ $.User.admin.ID }}'
|
||||
```
|
||||
|
||||
To select all users:
|
||||
|
||||
```go
|
||||
users := make([]User, 0)
|
||||
if err := db.NewSelect().Model(&users).OrderExpr("id ASC").Scan(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
To select a single user by id:
|
||||
|
||||
```go
|
||||
user1 := new(User)
|
||||
if err := db.NewSelect().Model(user1).Where("id = ?", 1).Scan(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
To select a story and the associated author in a single query:
|
||||
|
||||
```go
|
||||
story := new(Story)
|
||||
if err := db.NewSelect().
|
||||
Model(story).
|
||||
Relation("Author").
|
||||
Limit(1).
|
||||
Scan(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
To select a user into a map:
|
||||
|
||||
```go
|
||||
m := make(map[string]interface{})
|
||||
if err := db.NewSelect().
|
||||
Model((*User)(nil)).
|
||||
Limit(1).
|
||||
Scan(ctx, &m); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
To select all users scanning each column into a separate slice:
|
||||
|
||||
```go
|
||||
var ids []int64
|
||||
var names []string
|
||||
if err := db.NewSelect().
|
||||
ColumnExpr("id, name").
|
||||
Model((*User)(nil)).
|
||||
OrderExpr("id ASC").
|
||||
Scan(ctx, &ids, &names); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
For more details, please consult [docs](https://bun.uptrace.dev/) and check [examples](example).
|
||||
See [**Getting started**](https://bun.uptrace.dev/guide/getting-started.html) guide and check
|
||||
[examples](example).
|
||||
|
||||
## Contributors
|
||||
|
||||
|
|
|
|||
9
vendor/github.com/uptrace/bun/db.go
generated
vendored
9
vendor/github.com/uptrace/bun/db.go
generated
vendored
|
|
@ -203,6 +203,15 @@ func (db *DB) Formatter() schema.Formatter {
|
|||
return db.fmter
|
||||
}
|
||||
|
||||
// UpdateFQN returns a fully qualified column name. For MySQL, it returns the column name with
|
||||
// the table alias. For other RDBMS, it returns just the column name.
|
||||
func (db *DB) UpdateFQN(alias, column string) Ident {
|
||||
if db.HasFeature(feature.UpdateMultiTable) {
|
||||
return Ident(alias + "." + column)
|
||||
}
|
||||
return Ident(column)
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
|
|
|||
2
vendor/github.com/uptrace/bun/package.json
generated
vendored
2
vendor/github.com/uptrace/bun/package.json
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bun",
|
||||
"version": "1.0.18",
|
||||
"version": "1.0.19",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:uptrace/bun.git",
|
||||
"author": "Vladimir Mihailenco <vladimir.webdev@gmail.com>",
|
||||
|
|
|
|||
11
vendor/github.com/uptrace/bun/query_update.go
generated
vendored
11
vendor/github.com/uptrace/bun/query_update.go
generated
vendored
|
|
@ -452,9 +452,12 @@ func (q *UpdateQuery) afterUpdateHook(ctx context.Context) error {
|
|||
|
||||
// FQN returns a fully qualified column name. For MySQL, it returns the column name with
|
||||
// the table alias. For other RDBMS, it returns just the column name.
|
||||
func (q *UpdateQuery) FQN(name string) Ident {
|
||||
if q.db.fmter.HasFeature(feature.UpdateMultiTable) {
|
||||
return Ident(q.table.Alias + "." + name)
|
||||
func (q *UpdateQuery) FQN(column string) Ident {
|
||||
if q.table == nil {
|
||||
panic("UpdateQuery.FQN requires a model")
|
||||
}
|
||||
return Ident(name)
|
||||
if q.db.HasFeature(feature.UpdateMultiTable) {
|
||||
return Ident(q.table.Alias + "." + column)
|
||||
}
|
||||
return Ident(column)
|
||||
}
|
||||
|
|
|
|||
23
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
23
vendor/github.com/uptrace/bun/schema/table.go
generated
vendored
|
|
@ -285,8 +285,8 @@ func (t *Table) processBaseModelField(f reflect.StructField) {
|
|||
|
||||
if isKnownTableOption(tag.Name) {
|
||||
internal.Warn.Printf(
|
||||
"%s.%s tag name %q is also an option name; is it a mistake?",
|
||||
t.TypeName, f.Name, tag.Name,
|
||||
"%s.%s tag name %q is also an option name, is it a mistake? Try table:%s.",
|
||||
t.TypeName, f.Name, tag.Name, tag.Name,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -300,6 +300,10 @@ func (t *Table) processBaseModelField(f reflect.StructField) {
|
|||
t.setName(tag.Name)
|
||||
}
|
||||
|
||||
if s, ok := tag.Option("table"); ok {
|
||||
t.setName(s)
|
||||
}
|
||||
|
||||
if s, ok := tag.Option("select"); ok {
|
||||
t.SQLNameForSelects = t.quoteTableName(s)
|
||||
}
|
||||
|
|
@ -312,19 +316,23 @@ func (t *Table) processBaseModelField(f reflect.StructField) {
|
|||
|
||||
//nolint
|
||||
func (t *Table) newField(f reflect.StructField, index []int) *Field {
|
||||
sqlName := internal.Underscore(f.Name)
|
||||
tag := tagparser.Parse(f.Tag.Get("bun"))
|
||||
|
||||
sqlName := internal.Underscore(f.Name)
|
||||
if tag.Name != "" && tag.Name != sqlName {
|
||||
if isKnownFieldOption(tag.Name) {
|
||||
internal.Warn.Printf(
|
||||
"%s.%s tag name %q is also an option name; is it a mistake?",
|
||||
t.TypeName, f.Name, tag.Name,
|
||||
"%s.%s tag name %q is also an option name, is it a mistake? Try column:%s.",
|
||||
t.TypeName, f.Name, tag.Name, tag.Name,
|
||||
)
|
||||
}
|
||||
sqlName = tag.Name
|
||||
}
|
||||
|
||||
if s, ok := tag.Option("column"); ok {
|
||||
sqlName = s
|
||||
}
|
||||
|
||||
for name := range tag.Options {
|
||||
if !isKnownFieldOption(name) {
|
||||
internal.Warn.Printf("%s.%s has unknown tag option: %q", t.TypeName, f.Name, name)
|
||||
|
|
@ -854,7 +862,7 @@ func appendNew(dst []int, src ...int) []int {
|
|||
|
||||
func isKnownTableOption(name string) bool {
|
||||
switch name {
|
||||
case "alias", "select":
|
||||
case "table", "alias", "select":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -862,7 +870,8 @@ func isKnownTableOption(name string) bool {
|
|||
|
||||
func isKnownFieldOption(name string) bool {
|
||||
switch name {
|
||||
case "alias",
|
||||
case "column",
|
||||
"alias",
|
||||
"type",
|
||||
"array",
|
||||
"hstore",
|
||||
|
|
|
|||
2
vendor/github.com/uptrace/bun/version.go
generated
vendored
2
vendor/github.com/uptrace/bun/version.go
generated
vendored
|
|
@ -2,5 +2,5 @@ package bun
|
|||
|
||||
// Version is the current release version.
|
||||
func Version() string {
|
||||
return "1.0.18"
|
||||
return "1.0.19"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue