diff options
| author | 2025-03-09 17:47:56 +0100 | |
|---|---|---|
| committer | 2025-12-01 22:08:04 +0100 | |
| commit | b1af8fd87760b34e3ff2fd3bda38f211815a0473 (patch) | |
| tree | 9317fad1a7ec298d7a8d2678e4e422953bbc6f33 /vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go | |
| parent | [chore] update URLs to forked source (diff) | |
| download | gotosocial-b1af8fd87760b34e3ff2fd3bda38f211815a0473.tar.xz | |
[chore] remove vendor
Diffstat (limited to 'vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go')
| -rw-r--r-- | vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go deleted file mode 100644 index 029f7cb6d..000000000 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/hstore.go +++ /dev/null @@ -1,73 +0,0 @@ -package pgdialect - -import ( - "database/sql" - "fmt" - "reflect" - - "github.com/uptrace/bun/schema" -) - -type HStoreValue struct { - v reflect.Value - - append schema.AppenderFunc - scan schema.ScannerFunc -} - -// HStore accepts a map[string]string and returns a wrapper for working with PostgreSQL -// hstore data type. -// -// For struct fields you can use hstore tag: -// -// Attrs map[string]string `bun:",hstore"` -func HStore(vi interface{}) *HStoreValue { - v := reflect.ValueOf(vi) - if !v.IsValid() { - panic(fmt.Errorf("bun: HStore(nil)")) - } - - typ := v.Type() - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - } - if typ.Kind() != reflect.Map { - panic(fmt.Errorf("bun: Hstore(unsupported %s)", typ)) - } - - return &HStoreValue{ - v: v, - - append: pgDialect.hstoreAppender(v.Type()), - scan: hstoreScanner(v.Type()), - } -} - -var ( - _ schema.QueryAppender = (*HStoreValue)(nil) - _ sql.Scanner = (*HStoreValue)(nil) -) - -func (h *HStoreValue) AppendQuery(fmter schema.Formatter, b []byte) ([]byte, error) { - if h.append == nil { - panic(fmt.Errorf("bun: HStore(unsupported %s)", h.v.Type())) - } - return h.append(fmter, b, h.v), nil -} - -func (h *HStoreValue) Scan(src interface{}) error { - if h.scan == nil { - return fmt.Errorf("bun: HStore(unsupported %s)", h.v.Type()) - } - if h.v.Kind() != reflect.Ptr { - return fmt.Errorf("bun: HStore(non-pointer %s)", h.v.Type()) - } - return h.scan(h.v.Elem(), src) -} - -func (h *HStoreValue) Value() interface{} { - if h.v.IsValid() { - return h.v.Interface() - } - return nil -} |
