improved
This commit is contained in:
parent
d029b1ca86
commit
a3a11834dc
31
dialect.go
31
dialect.go
|
@ -27,28 +27,32 @@ type Dialect interface {
|
||||||
Init(*Uri, string, string) error
|
Init(*Uri, string, string) error
|
||||||
URI() *Uri
|
URI() *Uri
|
||||||
DBType() DbType
|
DBType() DbType
|
||||||
SqlType(t *Column) string
|
SqlType(*Column) string
|
||||||
SupportInsertMany() bool
|
|
||||||
QuoteStr() string
|
QuoteStr() string
|
||||||
AndStr() string
|
AndStr() string
|
||||||
|
OrStr() string
|
||||||
EqStr() string
|
EqStr() string
|
||||||
RollBackStr() string
|
RollBackStr() string
|
||||||
DropTableSql(tableName string) string
|
|
||||||
AutoIncrStr() string
|
AutoIncrStr() string
|
||||||
|
|
||||||
|
SupportInsertMany() bool
|
||||||
SupportEngine() bool
|
SupportEngine() bool
|
||||||
SupportCharset() bool
|
SupportCharset() bool
|
||||||
IndexOnTable() bool
|
IndexOnTable() bool
|
||||||
ShowCreateNull() bool
|
ShowCreateNull() bool
|
||||||
|
|
||||||
|
DropTableSql(tableName string) string
|
||||||
IndexCheckSql(tableName, idxName string) (string, []interface{})
|
IndexCheckSql(tableName, idxName string) (string, []interface{})
|
||||||
TableCheckSql(tableName string) (string, []interface{})
|
TableCheckSql(tableName string) (string, []interface{})
|
||||||
ColumnCheckSql(tableName, colName string) (string, []interface{})
|
ColumnCheckSql(tableName, colName string) (string, []interface{})
|
||||||
|
CreateTableSql(table *Table, tableName, storeEngine, charset string) string
|
||||||
|
CreateIndexSql(tableName string, index *Index) string
|
||||||
|
|
||||||
GetColumns(tableName string) ([]string, map[string]*Column, error)
|
GetColumns(tableName string) ([]string, map[string]*Column, error)
|
||||||
GetTables() ([]*Table, error)
|
GetTables() ([]*Table, error)
|
||||||
GetIndexes(tableName string) (map[string]*Index, error)
|
GetIndexes(tableName string) (map[string]*Index, error)
|
||||||
|
|
||||||
CreateTableSql(table *Table, tableName, storeEngine, charset string) string
|
|
||||||
Filters() []Filter
|
Filters() []Filter
|
||||||
|
|
||||||
DriverName() string
|
DriverName() string
|
||||||
|
@ -101,6 +105,10 @@ func (b *Base) AndStr() string {
|
||||||
return "AND"
|
return "AND"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Base) OrStr() string {
|
||||||
|
return "OR"
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Base) EqStr() string {
|
func (b *Base) EqStr() string {
|
||||||
return "="
|
return "="
|
||||||
}
|
}
|
||||||
|
@ -113,6 +121,21 @@ func (db *Base) DropTableSql(tableName string) string {
|
||||||
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`", tableName)
|
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`", tableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Base) CreateIndexSql(tableName string, index *Index) string {
|
||||||
|
quote := db.Quote
|
||||||
|
var unique string
|
||||||
|
var idxName string
|
||||||
|
if index.Type == UniqueType {
|
||||||
|
unique = " UNIQUE"
|
||||||
|
idxName = fmt.Sprintf("UQE_%v_%v", tableName, index.Name)
|
||||||
|
} else {
|
||||||
|
idxName = fmt.Sprintf("IDX_%v_%v", tableName, index.Name)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("CREATE%s INDEX %v ON %v (%v);", unique,
|
||||||
|
quote(idxName), quote(tableName),
|
||||||
|
quote(strings.Join(index.Cols, quote(","))))
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string {
|
func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string {
|
||||||
var sql string
|
var sql string
|
||||||
sql = "CREATE TABLE IF NOT EXISTS "
|
sql = "CREATE TABLE IF NOT EXISTS "
|
||||||
|
|
Loading…
Reference in New Issue