update dependencies #1

Open
nikooo777 wants to merge 2 commits from nikooo777/master into master
16 changed files with 828 additions and 382 deletions
Showing only changes of commit cfefe99de1 - Show all commits

View file

@ -2,7 +2,6 @@ package blobsdownloader
import (
"encoding/hex"
"io/ioutil"
"os"
"time"
@ -26,7 +25,7 @@ func DownloadBlob(hash string, save bool, blobsDir string) (*stream.Blob, error)
if err != nil {
return nil, errors.Err(err)
}
err = ioutil.WriteFile(blobsDir+hash, blob, 0644)
err = os.WriteFile(blobsDir+hash, blob, 0644)
if err != nil {
return nil, errors.Err(err)
}

View file

@ -1,8 +1,8 @@
package compression
import (
"io/ioutil"
"mime"
"os"
"path/filepath"
"github.com/lbryio/lbry.go/v2/extras/errors"
@ -21,7 +21,7 @@ func Compress(path, fileName, mimeType, storePath string) (string, string, error
return "", "", AlreadyInUseErr
}
defer inUse.Store(false)
file, err := ioutil.ReadFile(path)
file, err := os.ReadFile(path)
if err != nil {
return "", "", errors.Err(err)
}
@ -40,7 +40,7 @@ func Compress(path, fileName, mimeType, storePath string) (string, string, error
return "", "", errors.Err(err)
}
compressedPath := filepath.Join(storePath, fileName+".webp")
err = ioutil.WriteFile(compressedPath, webpBin, 0600)
err = os.WriteFile(compressedPath, webpBin, 0600)
if err != nil {
return "", "", errors.Err(err)
}

View file

@ -11,7 +11,7 @@ import (
"github.com/lbryio/lbry.go/v2/extras/errors"
migrate "github.com/rubenv/sql-migrate"
log "github.com/sirupsen/logrus"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/v4/boil"
)
// Init initializes a database connection based on the dsn provided. It also sets it as the global db connection.

View file

@ -8,7 +8,7 @@ import (
querytools "github.com/lbryio/lbry.go/v2/extras/query"
log "github.com/sirupsen/logrus"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/v4/boil"
)
func logQueryTime(logger *log.Logger, startTime time.Time) {

View file

@ -5,7 +5,7 @@ import (
"github.com/lbryio/lbry.go/v2/extras/errors"
log "github.com/sirupsen/logrus"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/v4/boil"
)
// TxFunc is a function that can be wrapped in a transaction

63
go.mod
View file

@ -1,29 +1,30 @@
module voidwalker
go 1.18
go 1.19
replace github.com/lbryio/lbry.go/v2 => github.com/OdyseeTeam/lbry.go/v2 v2.7.2-0.20230307181431-a01aa6dc0629
replace github.com/btcsuite/btcd => github.com/lbryio/lbrycrd.go v0.0.0-20200203050410-e1076f12bf19
require (
github.com/friendsofgo/errors v0.9.2
github.com/gabriel-vasile/mimetype v1.4.1
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.9.0
github.com/go-sql-driver/mysql v1.7.0
github.com/lbryio/lbry.go/v2 v2.7.2-0.20220321182539-d0aeb0c22b22
github.com/lbryio/reflector.go v1.1.3-0.20221017170156-0dfda70c7081
github.com/rubenv/sql-migrate v0.0.0-20200429072036-ae26b214fa43
github.com/sirupsen/logrus v1.9.0
github.com/go-sql-driver/mysql v1.7.1
github.com/lbryio/lbry.go/v2 v2.7.2-0.20230307181431-a01aa6dc0629
github.com/lbryio/reflector.go v1.1.3-0.20230309181259-456fe53e0174
github.com/rubenv/sql-migrate v1.4.0
github.com/sirupsen/logrus v1.9.2
github.com/sizeofint/gif-to-webp v0.0.0-20210224202734-e9d7ed071591
github.com/tkanos/gonfig v0.0.0-20210106201359-53e13348de2f
github.com/volatiletech/null v8.0.0+incompatible
github.com/volatiletech/sqlboiler v3.7.1+incompatible
github.com/volatiletech/null/v8 v8.1.2
github.com/volatiletech/sqlboiler/v4 v4.14.1
github.com/volatiletech/strmangle v0.0.4
go.uber.org/atomic v1.10.0
)
require (
github.com/DATA-DOG/go-sqlmock v1.5.0 // indirect
github.com/aws/aws-sdk-go v1.44.5 // indirect
github.com/aws/aws-sdk-go v1.44.217 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bluele/gcache v0.0.2 // indirect
github.com/brk0v/directio v0.0.0-20190225130936-69406e757cf7 // indirect
@ -33,66 +34,66 @@ require (
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/gofrs/uuid v3.2.0+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/karrick/godirwalk v1.17.0 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/lbryio/chainquery v1.8.1 // indirect
github.com/lbryio/lbry.go v1.1.2 // indirect
github.com/lbryio/chainquery v1.9.1-0.20230308044402-068c29e02865 // indirect
github.com/lbryio/types v0.0.0-20220224142228-73610f6654a6 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lyoshenka/bencode v0.0.0-20180323155644-b7abd7672df5 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/onsi/gomega v1.20.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sizeofint/webp-animation v0.0.0-20190207194838-b631dc900de9 // indirect
github.com/slack-go/slack v0.12.1 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/spf13/viper v1.15.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/volatiletech/inflect v0.0.0-20170731032912-e7201282ae8d // indirect
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/randomize v0.0.1 // indirect
github.com/ybbus/jsonrpc/v2 v2.1.7 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/gorp.v1 v1.7.2 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/nullbio/null.v6 v6.0.0-20161116030900-40264a2e6b79 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

842
go.sum

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"log"
"mime"
"net/http"
@ -37,8 +36,8 @@ import (
"github.com/lbryio/lbry.go/v2/extras/util"
"github.com/lbryio/lbry.go/v2/stream"
"github.com/sirupsen/logrus"
"github.com/volatiletech/null"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/null/v8"
"github.com/volatiletech/sqlboiler/v4/boil"
)
var publishAddress string
@ -292,7 +291,7 @@ func buildStream(sdBlob *stream.SDBlob, fileName string) error {
continue
}
hash := hex.EncodeToString(info.BlobHash)
blobToDecrypt, err := ioutil.ReadFile(blobsDir + hash)
blobToDecrypt, err := os.ReadFile(blobsDir + hash)
if err != nil {
return errors.Err(err)
}
@ -334,7 +333,7 @@ func downloadStream(sdHash string, fileName string) error {
return buildStream(sdb, fileName)
}
//var cache map[string]PublishResponse
// var cache map[string]PublishResponse
var cache *sync.Map //map[string]PublishResponse
func publish(c *gin.Context) {

View file

@ -1,14 +1,15 @@
// Code generated for package migration by go-bindata DO NOT EDIT. (@generated)
// Code generated by go-bindata. DO NOT EDIT.
// sources:
// migration/000_init_schema.sql
// migration/000_init_schema.sql (956B)
package migration
import (
"bytes"
"compress/gzip"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -18,7 +19,7 @@ import (
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
return nil, fmt.Errorf("read %q: %w", name, err)
}
var buf bytes.Buffer
@ -26,7 +27,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
return nil, fmt.Errorf("read %q: %w", name, err)
}
if clErr != nil {
return nil, err
@ -36,8 +37,9 @@ func bindataRead(data []byte, name string) ([]byte, error) {
}
type asset struct {
bytes []byte
info os.FileInfo
bytes []byte
info os.FileInfo
digest [sha256.Size]byte
}
type bindataFileInfo struct {
@ -47,32 +49,21 @@ type bindataFileInfo struct {
modTime time.Time
}
// Name return file name
func (fi bindataFileInfo) Name() string {
return fi.name
}
// Size return file size
func (fi bindataFileInfo) Size() int64 {
return fi.size
}
// Mode return file mode
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
}
// Mode return file modify time
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
}
// IsDir return file whether a directory
func (fi bindataFileInfo) IsDir() bool {
return fi.mode&os.ModeDir != 0
return false
}
// Sys return file is sys mode
func (fi bindataFileInfo) Sys() interface{} {
return nil
}
@ -93,7 +84,7 @@ func migration000_init_schemaSql() (*asset, error) {
}
info := bindataFileInfo{name: "migration/000_init_schema.sql", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfb, 0xc4, 0x9a, 0x9e, 0xf5, 0x39, 0xdc, 0x69, 0x9d, 0xe2, 0x11, 0x64, 0x2d, 0xd3, 0x19, 0x87, 0xc4, 0xc1, 0x94, 0xf0, 0x44, 0x8b, 0xc8, 0xac, 0x41, 0xed, 0x9d, 0xcd, 0xb9, 0x84, 0x5f, 0x7d}}
return a, nil
}
@ -101,8 +92,8 @@ func migration000_init_schemaSql() (*asset, error) {
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
@ -112,6 +103,12 @@ func Asset(name string) ([]byte, error) {
return nil, fmt.Errorf("Asset %s not found", name)
}
// AssetString returns the asset contents as a string (instead of a []byte).
func AssetString(name string) (string, error) {
data, err := Asset(name)
return string(data), err
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
@ -123,12 +120,18 @@ func MustAsset(name string) []byte {
return a
}
// MustAssetString is like AssetString but panics when Asset would return an
// error. It simplifies safe initialization of global variables.
func MustAssetString(name string) string {
return string(MustAsset(name))
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
@ -138,6 +141,33 @@ func AssetInfo(name string) (os.FileInfo, error) {
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetDigest returns the digest of the file with the given name. It returns an
// error if the asset could not be found or the digest could not be loaded.
func AssetDigest(name string) ([sha256.Size]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
}
return a.digest, nil
}
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
}
// Digests returns a map of all known files and their checksums.
func Digests() (map[string][sha256.Size]byte, error) {
mp := make(map[string][sha256.Size]byte, len(_bindata))
for name := range _bindata {
a, err := _bindata[name]()
if err != nil {
return nil, err
}
mp[name] = a.digest
}
return mp, nil
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
@ -152,24 +182,29 @@ var _bindata = map[string]func() (*asset, error){
"migration/000_init_schema.sql": migration000_init_schemaSql,
}
// AssetDebug is true if the assets were built with the debug flag enabled.
const AssetDebug = false
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
//
// data/
// foo.txt
// img/
// a.png
// b.png
//
// then AssetDir("data") would return []string{"foo.txt", "img"},
// AssetDir("data/img") would return []string{"a.png", "b.png"},
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
canonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(canonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
@ -193,12 +228,12 @@ type bintree struct {
}
var _bintree = &bintree{nil, map[string]*bintree{
"migration": &bintree{nil, map[string]*bintree{
"000_init_schema.sql": &bintree{migration000_init_schemaSql, map[string]*bintree{}},
"migration": {nil, map[string]*bintree{
"000_init_schema.sql": {migration000_init_schemaSql, map[string]*bintree{}},
}},
}}
// RestoreAsset restores an asset under the given directory
// RestoreAsset restores an asset under the given directory.
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
@ -212,18 +247,14 @@ func RestoreAsset(dir, name string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
err = os.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
}
// RestoreAssets restores an asset under the given directory recursively
// RestoreAssets restores an asset under the given directory recursively.
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
@ -241,6 +272,6 @@ func RestoreAssets(dir, name string) error {
}
func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
canonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
}

View file

@ -1,12 +1,14 @@
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model
import (
"github.com/volatiletech/sqlboiler/drivers"
"github.com/volatiletech/sqlboiler/queries"
"github.com/volatiletech/sqlboiler/queries/qm"
"regexp"
"github.com/volatiletech/sqlboiler/v4/drivers"
"github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm"
)
var dialect = drivers.Dialect{
@ -23,6 +25,9 @@ var dialect = drivers.Dialect{
UseCaseWhenExistsClause: false,
}
// This is a dummy variable to prevent unused regexp import error
var _ = &regexp.Regexp{}
// NewQuery initializes a new Query using the passed in QueryMods
func NewQuery(mods ...qm.QueryMod) *queries.Query {
q := &queries.Query{}

View file

@ -1,4 +1,4 @@
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model

View file

@ -1,4 +1,4 @@
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model
@ -7,8 +7,8 @@ import (
"strconv"
"github.com/friendsofgo/errors"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/strmangle"
"github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/strmangle"
)
// M type is for providing columns and column values to UpdateAll.

7
model/boil_view_names.go Normal file
View file

@ -0,0 +1,7 @@
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model
var ViewNames = struct {
}{}

View file

@ -1,4 +1,4 @@
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model
@ -7,8 +7,8 @@ import (
"fmt"
"strings"
"github.com/volatiletech/sqlboiler/drivers"
"github.com/volatiletech/sqlboiler/strmangle"
"github.com/volatiletech/sqlboiler/v4/drivers"
"github.com/volatiletech/strmangle"
)
// buildUpsertQueryMySQL builds a SQL statement string using the upsertData provided.

View file

@ -1,4 +1,4 @@
// Code generated by SQLBoiler 3.7.1 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// Code generated by SQLBoiler 4.14.2 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package model
@ -13,12 +13,12 @@ import (
"time"
"github.com/friendsofgo/errors"
"github.com/volatiletech/null"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/queries"
"github.com/volatiletech/sqlboiler/queries/qm"
"github.com/volatiletech/sqlboiler/queries/qmhelper"
"github.com/volatiletech/sqlboiler/strmangle"
"github.com/volatiletech/null/v8"
"github.com/volatiletech/sqlboiler/v4/boil"
"github.com/volatiletech/sqlboiler/v4/queries"
"github.com/volatiletech/sqlboiler/v4/queries/qm"
"github.com/volatiletech/sqlboiler/v4/queries/qmhelper"
"github.com/volatiletech/strmangle"
)
// Thumbnail is an object representing the database table.
@ -53,6 +53,24 @@ var ThumbnailColumns = struct {
UpdatedAt: "updated_at",
}
var ThumbnailTableColumns = struct {
ID string
Name string
CompressedName string
CompressedMimeType string
Compressed string
CreatedAt string
UpdatedAt string
}{
ID: "thumbnail.id",
Name: "thumbnail.name",
CompressedName: "thumbnail.compressed_name",
CompressedMimeType: "thumbnail.compressed_mime_type",
Compressed: "thumbnail.compressed",
CreatedAt: "thumbnail.created_at",
UpdatedAt: "thumbnail.updated_at",
}
// Generated where
type whereHelperuint64 struct{ field string }
@ -70,6 +88,13 @@ func (w whereHelperuint64) IN(slice []uint64) qm.QueryMod {
}
return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...)
}
func (w whereHelperuint64) NIN(slice []uint64) qm.QueryMod {
values := make([]interface{}, 0, len(slice))
for _, value := range slice {
values = append(values, value)
}
return qm.WhereNotIn(fmt.Sprintf("%s NOT IN ?", w.field), values...)
}
type whereHelperstring struct{ field string }
@ -86,6 +111,13 @@ func (w whereHelperstring) IN(slice []string) qm.QueryMod {
}
return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...)
}
func (w whereHelperstring) NIN(slice []string) qm.QueryMod {
values := make([]interface{}, 0, len(slice))
for _, value := range slice {
values = append(values, value)
}
return qm.WhereNotIn(fmt.Sprintf("%s NOT IN ?", w.field), values...)
}
type whereHelpernull_String struct{ field string }
@ -95,8 +127,6 @@ func (w whereHelpernull_String) EQ(x null.String) qm.QueryMod {
func (w whereHelpernull_String) NEQ(x null.String) qm.QueryMod {
return qmhelper.WhereNullEQ(w.field, true, x)
}
func (w whereHelpernull_String) IsNull() qm.QueryMod { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpernull_String) IsNotNull() qm.QueryMod { return qmhelper.WhereIsNotNull(w.field) }
func (w whereHelpernull_String) LT(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.LT, x)
}
@ -109,6 +139,23 @@ func (w whereHelpernull_String) GT(x null.String) qm.QueryMod {
func (w whereHelpernull_String) GTE(x null.String) qm.QueryMod {
return qmhelper.Where(w.field, qmhelper.GTE, x)
}
func (w whereHelpernull_String) IN(slice []string) qm.QueryMod {
values := make([]interface{}, 0, len(slice))
for _, value := range slice {
values = append(values, value)
}
return qm.WhereIn(fmt.Sprintf("%s IN ?", w.field), values...)
}
func (w whereHelpernull_String) NIN(slice []string) qm.QueryMod {
values := make([]interface{}, 0, len(slice))
for _, value := range slice {
values = append(values, value)
}
return qm.WhereNotIn(fmt.Sprintf("%s NOT IN ?", w.field), values...)
}
func (w whereHelpernull_String) IsNull() qm.QueryMod { return qmhelper.WhereIsNull(w.field) }
func (w whereHelpernull_String) IsNotNull() qm.QueryMod { return qmhelper.WhereIsNotNull(w.field) }
type whereHelperbool struct{ field string }
@ -179,11 +226,12 @@ var (
thumbnailColumnsWithoutDefault = []string{"name", "compressed_name", "compressed_mime_type", "compressed"}
thumbnailColumnsWithDefault = []string{"id", "created_at", "updated_at"}
thumbnailPrimaryKeyColumns = []string{"id"}
thumbnailGeneratedColumns = []string{}
)
type (
// ThumbnailSlice is an alias for a slice of pointers to Thumbnail.
// This should generally be used opposed to []Thumbnail.
// This should almost always be used instead of []Thumbnail.
ThumbnailSlice []*Thumbnail
thumbnailQuery struct {
@ -245,7 +293,7 @@ func (q thumbnailQuery) One(exec boil.Executor) (*Thumbnail, error) {
err := q.Bind(nil, exec, o)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
if errors.Is(err, sql.ErrNoRows) {
return nil, sql.ErrNoRows
}
return nil, errors.Wrap(err, "model: failed to execute a one query for thumbnail")
@ -291,7 +339,7 @@ func (q thumbnailQuery) All(exec boil.Executor) (ThumbnailSlice, error) {
return o, nil
}
// CountG returns the count of all Thumbnail records in the query, and panics on error.
// CountG returns the count of all Thumbnail records in the query using the global executor
func (q thumbnailQuery) CountG() (int64, error) {
return q.Count(boil.GetDB())
}
@ -331,7 +379,7 @@ func (q thumbnailQuery) Count(exec boil.Executor) (int64, error) {
return count, nil
}
// ExistsG checks if the row exists in the table, and panics on error.
// ExistsG checks if the row exists in the table using the global executor.
func (q thumbnailQuery) ExistsG() (bool, error) {
return q.Exists(boil.GetDB())
}
@ -375,7 +423,12 @@ func (q thumbnailQuery) Exists(exec boil.Executor) (bool, error) {
// Thumbnails retrieves all the records using an executor.
func Thumbnails(mods ...qm.QueryMod) thumbnailQuery {
mods = append(mods, qm.From("`thumbnail`"))
return thumbnailQuery{NewQuery(mods...)}
q := NewQuery(mods...)
if len(queries.GetSelect(q)) == 0 {
queries.SetSelect(q, []string{"`thumbnail`.*"})
}
return thumbnailQuery{q}
}
// FindThumbnailG retrieves a single record by ID.
@ -420,7 +473,7 @@ func FindThumbnail(exec boil.Executor, iD uint64, selectCols ...string) (*Thumbn
err := q.Bind(nil, exec, thumbnailObj)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
if errors.Is(err, sql.ErrNoRows) {
return nil, sql.ErrNoRows
}
return nil, errors.Wrap(err, "model: unable to select from thumbnail")
@ -589,7 +642,6 @@ func (o *Thumbnail) Update(exec boil.Executor, columns boil.Columns) error {
thumbnailAllColumns,
thumbnailPrimaryKeyColumns,
)
if len(wl) == 0 {
return errors.New("model: unable to update thumbnail, could not build whitelist")
}
@ -637,6 +689,14 @@ func (q thumbnailQuery) UpdateAllG(cols M) error {
return q.UpdateAll(boil.GetDB(), cols)
}
// UpdateAllGP updates all rows with the specified column values, and panics on error.
func (q thumbnailQuery) UpdateAllGP(cols M) {
err := q.UpdateAll(boil.GetDB(), cols)
if err != nil {
panic(boil.WrapErr(err))
}
}
// UpdateAll updates all rows with the specified column values.
func (q thumbnailQuery) UpdateAll(exec boil.Executor, cols M) error {
queries.SetUpdate(q.Query, cols)
@ -788,17 +848,18 @@ func (o *Thumbnail) Upsert(exec boil.Executor, updateColumns, insertColumns boil
thumbnailColumnsWithoutDefault,
nzDefaults,
)
update := updateColumns.UpdateColumnSet(
thumbnailAllColumns,
thumbnailPrimaryKeyColumns,
)
if len(update) == 0 {
if !updateColumns.IsNone() && len(update) == 0 {
return errors.New("model: unable to upsert thumbnail, could not build update column list")
}
ret = strmangle.SetComplement(ret, nzUniques)
cache.query = buildUpsertQueryMySQL(dialect, "thumbnail", update, insert)
cache.query = buildUpsertQueryMySQL(dialect, "`thumbnail`", update, insert)
cache.retQuery = fmt.Sprintf(
"SELECT %s FROM `thumbnail` WHERE %s",
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, ret), ","),
@ -925,6 +986,10 @@ func (o *Thumbnail) Delete(exec boil.Executor) error {
return nil
}
func (q thumbnailQuery) DeleteAllG() error {
return q.DeleteAll(boil.GetDB())
}
// DeleteAllP deletes all rows, and panics on error.
func (q thumbnailQuery) DeleteAllP(exec boil.Executor) {
err := q.DeleteAll(exec)
@ -933,6 +998,14 @@ func (q thumbnailQuery) DeleteAllP(exec boil.Executor) {
}
}
// DeleteAllGP deletes all rows, and panics on error.
func (q thumbnailQuery) DeleteAllGP() {
err := q.DeleteAll(boil.GetDB())
if err != nil {
panic(boil.WrapErr(err))
}
}
// DeleteAll deletes all matching rows.
func (q thumbnailQuery) DeleteAll(exec boil.Executor) error {
if q.Query == nil {
@ -1132,3 +1205,8 @@ func ThumbnailExists(exec boil.Executor, iD uint64) (bool, error) {
return exists, nil
}
// Exists checks if the Thumbnail row exists.
func (o *Thumbnail) Exists(exec boil.Executor) (bool, error) {
return ThumbnailExists(exec, o.ID)
}

View file

@ -1,12 +1,8 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
cd ".."
DIR="$PWD"
(
cd "$DIR"
go get -u -t github.com/volatiletech/sqlboiler@v3.7.1
go get -u -t github.com/volatiletech/sqlboiler/drivers/sqlboiler-mysql@v3.7.1
cd "$DIR/.."
go install github.com/volatiletech/sqlboiler/v4@latest
sqlboiler --no-rows-affected --no-auto-timestamps --no-hooks --no-tests --no-context --add-global-variants --add-panic-variants --wipe mysql
)