summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-07-12 18:19:03 -0800
committer=Corey Hulen <corey@hulen.com>2015-07-12 19:28:58 -0800
commit34d56294a240a38722d2d752c63ce087de625080 (patch)
tree4ff25d543b9789a700afc08eb16e0e586bbb830f /store/sql_store.go
parentff21a5c75f090d5c27446eeaa6fb3ff6f82c5ab4 (diff)
downloadchat-34d56294a240a38722d2d752c63ce087de625080.tar.gz
chat-34d56294a240a38722d2d752c63ce087de625080.tar.bz2
chat-34d56294a240a38722d2d752c63ce087de625080.zip
Patching remainder of the sql stmts to work with postgres
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index 4ec954042..543945605 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -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
}