From fef024b600e0f0429c83e3e2908c0ec51c9d4b84 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 28 Aug 2014 23:13:04 +0800 Subject: [PATCH] bug fixed for sqlite3 dialect --- sqlite3_dialect.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sqlite3_dialect.go b/sqlite3_dialect.go index ddf6a5f2..e8d6cf2c 100644 --- a/sqlite3_dialect.go +++ b/sqlite3_dialect.go @@ -84,6 +84,21 @@ func (db *sqlite3) TableCheckSql(tableName string) (string, []interface{}) { return "SELECT name FROM sqlite_master WHERE type='table' and name = ?", args } +func (db *sqlite3) DropIndexSql(tableName string, index *core.Index) string { + quote := db.Quote + //var unique string + var idxName string = index.Name + if !strings.HasPrefix(idxName, "UQE_") && + !strings.HasPrefix(idxName, "IDX_") { + if index.Type == core.UniqueType { + idxName = fmt.Sprintf("UQE_%v_%v", tableName, index.Name) + } else { + idxName = fmt.Sprintf("IDX_%v_%v", tableName, index.Name) + } + } + return fmt.Sprintf("DROP INDEX %v", quote(idxName)) +} + /*func (db *sqlite3) ColumnCheckSql(tableName, colName string) (string, []interface{}) { args := []interface{}{tableName} sql := "SELECT name FROM sqlite_master WHERE type='table' and name = ? and ((sql like '%`" + colName + "`%') or (sql like '%[" + colName + "]%'))"