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() {}
|
func (m *MockDriver) Close() {}
|
||||||
|
|
||||||
// RightQuote is the quoting character for the right side of the identifier
|
// RightQuote is the quoting character for the right side of the identifier
|
||||||
func (m *MockDriver) RightQuote() string {
|
func (m *MockDriver) RightQuote() byte {
|
||||||
return "`"
|
return '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeftQuote is the quoting character for the left side of the identifier
|
// LeftQuote is the quoting character for the left side of the identifier
|
||||||
func (m *MockDriver) LeftQuote() string {
|
func (m *MockDriver) LeftQuote() byte {
|
||||||
return `"`
|
return '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// IndexPlaceholders returns true to indicate fake support of indexed placeholders
|
// 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
|
// RightQuote is the quoting character for the right side of the identifier
|
||||||
func (m *MySQLDriver) RightQuote() string {
|
func (m *MySQLDriver) RightQuote() byte {
|
||||||
return "`"
|
return '`'
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeftQuote is the quoting character for the left side of the identifier
|
// LeftQuote is the quoting character for the left side of the identifier
|
||||||
func (m *MySQLDriver) LeftQuote() string {
|
func (m *MySQLDriver) LeftQuote() byte {
|
||||||
return "`"
|
return '`'
|
||||||
}
|
}
|
||||||
|
|
||||||
// IndexPlaceholders returns false to indicate MySQL doesnt support indexed placeholders
|
// 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
|
// RightQuote is the quoting character for the right side of the identifier
|
||||||
func (p *PostgresDriver) RightQuote() string {
|
func (p *PostgresDriver) RightQuote() byte {
|
||||||
return `"`
|
return '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeftQuote is the quoting character for the left side of the identifier
|
// LeftQuote is the quoting character for the left side of the identifier
|
||||||
func (p *PostgresDriver) LeftQuote() string {
|
func (p *PostgresDriver) LeftQuote() byte {
|
||||||
return `"`
|
return '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
// IndexPlaceholders returns true to indicate PSQL supports indexed placeholders
|
// 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
|
// Dialect helpers, these provide the values that will go into
|
||||||
// a boil.Dialect, so the query builder knows how to support
|
// a boil.Dialect, so the query builder knows how to support
|
||||||
// your database driver properly.
|
// your database driver properly.
|
||||||
LeftQuote() string
|
LeftQuote() byte
|
||||||
RightQuote() string
|
RightQuote() byte
|
||||||
IndexPlaceholders() bool
|
IndexPlaceholders() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ type Query struct {
|
||||||
// that provide these values.
|
// that provide these values.
|
||||||
type Dialect struct {
|
type Dialect struct {
|
||||||
// The left quote character for SQL identifiers
|
// The left quote character for SQL identifiers
|
||||||
LQ string
|
LQ byte
|
||||||
// The right quote character for SQL identifiers
|
// The right quote character for SQL identifiers
|
||||||
RQ string
|
RQ byte
|
||||||
// Bool flag indicating whether indexed
|
// Bool flag indicating whether indexed
|
||||||
// placeholders ($1) are used, or ? placeholders.
|
// placeholders ($1) are used, or ? placeholders.
|
||||||
IndexPlaceholders bool
|
IndexPlaceholders bool
|
||||||
|
|
|
@ -46,18 +46,6 @@ func SchemaTable(driver string, schema string, table string) string {
|
||||||
return fmt.Sprintf(`"%s"`, table)
|
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
|
// IdentQuote attempts to quote simple identifiers in SQL tatements
|
||||||
func IdentQuote(s string) string {
|
func IdentQuote(s string) string {
|
||||||
if strings.ToLower(s) == "null" {
|
if strings.ToLower(s) == "null" {
|
||||||
|
|
|
@ -117,7 +117,6 @@ var templateFunctions = template.FuncMap{
|
||||||
// String ops
|
// String ops
|
||||||
"quoteWrap": func(a string) string { return fmt.Sprintf(`"%s"`, a) },
|
"quoteWrap": func(a string) string { return fmt.Sprintf(`"%s"`, a) },
|
||||||
"id": strmangle.Identifier,
|
"id": strmangle.Identifier,
|
||||||
"wrapQuote": strmangle.WrapQuote,
|
|
||||||
|
|
||||||
// Pluralization
|
// Pluralization
|
||||||
"singular": strmangle.Singular,
|
"singular": strmangle.Singular,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var dialect boil.Dialect = boil.Dialect{
|
var dialect boil.Dialect = boil.Dialect{
|
||||||
LQ: {{wrapQuote .Dialect.LQ}},
|
LQ: 0x{{printf "%x" .Dialect.LQ}},
|
||||||
RQ: {{wrapQuote .Dialect.RQ}},
|
RQ: 0x{{printf "%x" .Dialect.RQ}},
|
||||||
IndexPlaceholders: {{.Dialect.IndexPlaceholders}},
|
IndexPlaceholders: {{.Dialect.IndexPlaceholders}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue