Change quotes to bytes

This commit is contained in:
Patrick O'brien 2016-09-10 03:30:46 +10:00
parent 9e6a3d5ee3
commit 419f2760c7
8 changed files with 18 additions and 31 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
} }

View file

@ -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

View file

@ -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" {

View file

@ -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,

View file

@ -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}},
} }