Patching remainder of the sql stmts to work with postgres

Этот коммит содержится в:
=Corey Hulen
2015-07-12 18:19:03 -08:00
родитель ff21a5c75f
Коммит 34d56294a2
9 изменённых файлов: 123 добавлений и 75 удалений

Просмотреть файл

@@ -25,6 +25,7 @@ import (
sqltrace "log"
"math/rand"
"os"
"strings"
"time"
)
@@ -123,10 +124,6 @@ func setupConnection(con_type string, driver string, dataSource string, maxIdle
func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, colType string, defaultValue string) bool {
// SELECT column_name
// FROM information_schema.columns
// WHERE table_name='your_table' and column_name='your_column';
var count int64
var err error
@@ -272,6 +269,12 @@ func (ss SqlStore) createIndexIfNotExists(indexName string, tableName string, co
}
}
func IsUniqueConstraintError(err string, mysql string, postgres string) bool {
unique := strings.Contains(err, "unique constraint") || strings.Contains(err, "Duplicate entry")
field := strings.Contains(err, mysql) || strings.Contains(err, postgres)
return unique && field
}
func (ss SqlStore) GetMaster() *gorp.DbMap {
return ss.master
}