mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: wraps the bytes.Buffer methods to make them chainable
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user