interface changed for adding dropifexist
This commit is contained in:
parent
a9aba4b935
commit
c6d2321d63
16
dialect.go
16
dialect.go
|
@ -47,6 +47,7 @@ type Dialect interface {
|
||||||
SupportInsertMany() bool
|
SupportInsertMany() bool
|
||||||
SupportEngine() bool
|
SupportEngine() bool
|
||||||
SupportCharset() bool
|
SupportCharset() bool
|
||||||
|
SupportDropIfExists() bool
|
||||||
IndexOnTable() bool
|
IndexOnTable() bool
|
||||||
ShowCreateNull() bool
|
ShowCreateNull() bool
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ type Dialect interface {
|
||||||
ModifyColumnSql(tableName string, col *Column) string
|
ModifyColumnSql(tableName string, col *Column) string
|
||||||
|
|
||||||
//CreateTableIfNotExists(table *Table, tableName, storeEngine, charset string) error
|
//CreateTableIfNotExists(table *Table, tableName, storeEngine, charset string) error
|
||||||
MustDropTable(tableName string) error
|
//MustDropTable(tableName string) error
|
||||||
|
|
||||||
GetColumns(tableName string) ([]string, map[string]*Column, error)
|
GetColumns(tableName string) ([]string, map[string]*Column, error)
|
||||||
GetTables() ([]*Table, error)
|
GetTables() ([]*Table, error)
|
||||||
|
@ -139,17 +140,12 @@ func (db *Base) RollBackStr() string {
|
||||||
return "ROLL BACK"
|
return "ROLL BACK"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Base) DropTableSql(tableName string) string {
|
func (db *Base) SupportDropIfExists() bool {
|
||||||
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`;", tableName)
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Base) MustDropTable(tableName string) error {
|
func (db *Base) DropTableSql(tableName string) string {
|
||||||
query := db.DropTableSql(tableName)
|
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`", tableName)
|
||||||
_, err := db.db.Exec(query)
|
|
||||||
if db.Logger != nil {
|
|
||||||
db.Logger.Info("[sql]", query)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Base) HasRecords(query string, args ...interface{}) (bool, error) {
|
func (db *Base) HasRecords(query string, args ...interface{}) (bool, error) {
|
||||||
|
|
Loading…
Reference in New Issue