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/array_parser.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/array_parser.go')
| -rw-r--r-- | vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go b/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go deleted file mode 100644 index 56db9fd07..000000000 --- a/vendor/github.com/uptrace/bun/dialect/pgdialect/array_parser.go +++ /dev/null @@ -1,119 +0,0 @@ -package pgdialect - -import ( - "bytes" - "fmt" - "io" -) - -type arrayParser struct { - p pgparser - - elem []byte - err error - - isJson bool -} - -func newArrayParser(b []byte) *arrayParser { - p := new(arrayParser) - - if b[0] == 'n' { - p.p.Reset(nil) - return p - } - - if len(b) < 2 || (b[0] != '{' && b[0] != '[') || (b[len(b)-1] != '}' && b[len(b)-1] != ']') { - p.err = fmt.Errorf("pgdialect: can't parse array: %q", b) - return p - } - p.isJson = b[0] == '[' - - p.p.Reset(b[1 : len(b)-1]) - return p -} - -func (p *arrayParser) Next() bool { - if p.err != nil { - return false - } - p.err = p.readNext() - return p.err == nil -} - -func (p *arrayParser) Err() error { - if p.err != io.EOF { - return p.err - } - return nil -} - -func (p *arrayParser) Elem() []byte { - return p.elem -} - -func (p *arrayParser) readNext() error { - ch := p.p.Read() - if ch == 0 { - return io.EOF - } - - switch ch { - case '}', ']': - return io.EOF - case '"': - b, err := p.p.ReadSubstring(ch) - if err != nil { - return err - } - - if p.p.Peek() == ',' { - p.p.Advance() - } - - p.elem = b - return nil - case '[', '(': - rng, err := p.p.ReadRange(ch) - if err != nil { - return err - } - - if p.p.Peek() == ',' { - p.p.Advance() - } - - p.elem = rng - return nil - default: - if ch == '{' && p.isJson { - json, err := p.p.ReadJSON() - if err != nil { - return err - } - - for { - if p.p.Peek() == ',' || p.p.Peek() == ' ' { - p.p.Advance() - } else { - break - } - } - - p.elem = json - return nil - } else { - lit := p.p.ReadLiteral(ch) - if bytes.Equal(lit, []byte("NULL")) { - lit = nil - } - - if p.p.Peek() == ',' { - p.p.Advance() - } - - p.elem = lit - return nil - } - } -} |
