dialect/sql: wraps the bytes.Buffer methods to make them chainable

This commit is contained in:
Ariel Mashraki
2020-08-26 16:13:26 +03:00
parent 038670335c
commit 0d23ef86de

View File

@@ -1839,16 +1839,6 @@ func (b *Builder) Quote(ident string) string {
}
}
// isIdent reports if the given string is a dialect identifier.
func (b *Builder) isIdent(s string) bool {
switch {
case b.postgres():
return strings.Contains(s, `"`)
default:
return strings.Contains(s, "`")
}
}
// Ident appends the given string as an identifier.
func (b *Builder) Ident(s string) *Builder {
switch {
@@ -1876,6 +1866,18 @@ func (b *Builder) IdentComma(s ...string) *Builder {
return b
}
// WriteByte wraps the Buffer.WriteByte to make it chainable with other methods.
func (b *Builder) WriteByte(c byte) *Builder {
b.Buffer.WriteByte(c)
return b
}
// WriteString wraps the Buffer.WriteString to make it chainable with other methods.
func (b *Builder) WriteString(s string) *Builder {
b.Buffer.WriteString(s)
return b
}
// JSONOption allows for calling database JSON paths with functional options.
type JSONOption func(*JSONPath)
@@ -2110,6 +2112,16 @@ func (b *Builder) fromIdent(ident string) {
// otherwise, use the default.
}
// isIdent reports if the given string is a dialect identifier.
func (b *Builder) isIdent(s string) bool {
switch {
case b.postgres():
return strings.Contains(s, `"`)
default:
return strings.Contains(s, "`")
}
}
// state wraps the all methods for setting and getting
// update state between all queries in the query tree.
type state interface {