Commit e164a790 authored by Jason Moiron's avatar Jason Moiron

add DriverName to the dialect interface (required for interfacing with newer...

add DriverName to the dialect interface (required for interfacing with newer sqlx) and change NewDbMap to work with newer sqlx
parent 794a78b4
......@@ -37,7 +37,7 @@ type DbMap struct {
// Return a new DbMap using the db connection and dialect
func NewDbMap(db *sql.DB, dialect Dialect) *DbMap {
return &DbMap{Db: db, Dialect: dialect, Dbx: &sqlx.DB{*db}}
return &DbMap{Db: db, Dialect: dialect, Dbx: sqlx.NewDb(db, dialect.DriverName())}
}
// TraceOn turns on SQL statement logging for this DbMap. After this is
......
......@@ -41,6 +41,9 @@ type Dialect interface {
// Handles quoting of a field name to ensure that it doesn't raise any
// SQL parsing exceptions by using a reserved word as a field name.
QuoteField(field string) string
// Get the driver name from a dialect
DriverName() string
}
func standardInsertAutoIncr(exec SqlExecutor, insertSql string, params ...interface{}) (int64, error) {
......@@ -59,6 +62,10 @@ type SqliteDialect struct {
suffix string
}
func (d SqliteDialect) DriverName() string {
return "sqlite"
}
func (d SqliteDialect) ToSqlType(col *ColumnMap) string {
switch col.gotype.Kind() {
case reflect.Bool:
......@@ -130,6 +137,10 @@ type PostgresDialect struct {
suffix string
}
func (d PostgresDialect) DriverName() string {
return "postgres"
}
func (d PostgresDialect) ToSqlType(col *ColumnMap) string {
switch col.gotype.Kind() {
......@@ -228,6 +239,10 @@ type MySQLDialect struct {
Encoding string
}
func (d MySQLDialect) DriverName() string {
return "mysql"
}
func (m MySQLDialect) ToSqlType(col *ColumnMap) string {
switch col.gotype.Kind() {
case reflect.Bool:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment