Change quotes to bytes
This commit is contained in:
parent
9e6a3d5ee3
commit
419f2760c7
8 changed files with 18 additions and 31 deletions
|
@ -125,13 +125,13 @@ func (m *MockDriver) Open() error { return nil }
|
|||
func (m *MockDriver) Close() {}
|
||||
|
||||
// RightQuote is the quoting character for the right side of the identifier
|
||||
func (m *MockDriver) RightQuote() string {
|
||||
return "`"
|
||||
func (m *MockDriver) RightQuote() byte {
|
||||
return '"'
|
||||
}
|
||||
|
||||
// LeftQuote is the quoting character for the left side of the identifier
|
||||
func (m *MockDriver) LeftQuote() string {
|
||||
return `"`
|
||||
func (m *MockDriver) LeftQuote() byte {
|
||||
return '"'
|
||||
}
|
||||
|
||||
// IndexPlaceholders returns true to indicate fake support of indexed placeholders
|
||||
|
|
|
@ -320,13 +320,13 @@ func mySQLIsValidated(typ string) bool {
|
|||
}
|
||||
|
||||
// RightQuote is the quoting character for the right side of the identifier
|
||||
func (m *MySQLDriver) RightQuote() string {
|
||||
return "`"
|
||||
func (m *MySQLDriver) RightQuote() byte {
|
||||
return '`'
|
||||
}
|
||||
|
||||
// LeftQuote is the quoting character for the left side of the identifier
|
||||
func (m *MySQLDriver) LeftQuote() string {
|
||||
return "`"
|
||||
func (m *MySQLDriver) LeftQuote() byte {
|
||||
return '`'
|
||||
}
|
||||
|
||||
// IndexPlaceholders returns false to indicate MySQL doesnt support indexed placeholders
|
||||
|
|
|
@ -342,13 +342,13 @@ func psqlIsValidated(typ string) bool {
|
|||
}
|
||||
|
||||
// RightQuote is the quoting character for the right side of the identifier
|
||||
func (p *PostgresDriver) RightQuote() string {
|
||||
return `"`
|
||||
func (p *PostgresDriver) RightQuote() byte {
|
||||
return '"'
|
||||
}
|
||||
|
||||
// LeftQuote is the quoting character for the left side of the identifier
|
||||
func (p *PostgresDriver) LeftQuote() string {
|
||||
return `"`
|
||||
func (p *PostgresDriver) LeftQuote() byte {
|
||||
return '"'
|
||||
}
|
||||
|
||||
// IndexPlaceholders returns true to indicate PSQL supports indexed placeholders
|
||||
|
|
|
@ -26,8 +26,8 @@ type Interface interface {
|
|||
// Dialect helpers, these provide the values that will go into
|
||||
// a boil.Dialect, so the query builder knows how to support
|
||||
// your database driver properly.
|
||||
LeftQuote() string
|
||||
RightQuote() string
|
||||
LeftQuote() byte
|
||||
RightQuote() byte
|
||||
IndexPlaceholders() bool
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ type Query struct {
|
|||
// that provide these values.
|
||||
type Dialect struct {
|
||||
// The left quote character for SQL identifiers
|
||||
LQ string
|
||||
LQ byte
|
||||
// The right quote character for SQL identifiers
|
||||
RQ string
|
||||
RQ byte
|
||||
// Bool flag indicating whether indexed
|
||||
// placeholders ($1) are used, or ? placeholders.
|
||||
IndexPlaceholders bool
|
||||
|
|
|
@ -46,18 +46,6 @@ func SchemaTable(driver string, schema string, table string) string {
|
|||
return fmt.Sprintf(`"%s"`, table)
|
||||
}
|
||||
|
||||
// WrapQuote wraps a quote character in quotes.
|
||||
func WrapQuote(s string) string {
|
||||
if s == `"` {
|
||||
return "`\"`"
|
||||
}
|
||||
if s == "`" {
|
||||
return "\"`\""
|
||||
}
|
||||
|
||||
return fmt.Sprintf("`%s`", s)
|
||||
}
|
||||
|
||||
// IdentQuote attempts to quote simple identifiers in SQL tatements
|
||||
func IdentQuote(s string) string {
|
||||
if strings.ToLower(s) == "null" {
|
||||
|
|
|
@ -117,7 +117,6 @@ var templateFunctions = template.FuncMap{
|
|||
// String ops
|
||||
"quoteWrap": func(a string) string { return fmt.Sprintf(`"%s"`, a) },
|
||||
"id": strmangle.Identifier,
|
||||
"wrapQuote": strmangle.WrapQuote,
|
||||
|
||||
// Pluralization
|
||||
"singular": strmangle.Singular,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var dialect boil.Dialect = boil.Dialect{
|
||||
LQ: {{wrapQuote .Dialect.LQ}},
|
||||
RQ: {{wrapQuote .Dialect.RQ}},
|
||||
LQ: 0x{{printf "%x" .Dialect.LQ}},
|
||||
RQ: 0x{{printf "%x" .Dialect.RQ}},
|
||||
IndexPlaceholders: {{.Dialect.IndexPlaceholders}},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue