summaryrefslogtreecommitdiffstats
path: root/store/sql_store.go
diff options
context:
space:
mode:
authorFlorian Orben <florian.orben@gmail.com>2015-11-05 23:55:31 +0100
committerFlorian Orben <florian.orben@gmail.com>2015-11-05 23:55:31 +0100
commite00836f8df00670e8c02daad7e02a13283ddb92f (patch)
tree5cc4eb804d554caf36ab483c8c0f14f4be92bdb4 /store/sql_store.go
parentb085bc2d56bdc98101b8cb50848aee248d42af28 (diff)
downloadchat-e00836f8df00670e8c02daad7e02a13283ddb92f.tar.gz
chat-e00836f8df00670e8c02daad7e02a13283ddb92f.tar.bz2
chat-e00836f8df00670e8c02daad7e02a13283ddb92f.zip
postgres needs another query to get table information...
Diffstat (limited to 'store/sql_store.go')
-rw-r--r--store/sql_store.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/store/sql_store.go b/store/sql_store.go
index d2cca21d0..697c89589 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -50,15 +50,6 @@ type SqlStore struct {
preference PreferenceStore
}
-type Column struct {
- Field string
- Type string
- Null string
- Key interface{}
- Default interface{}
- Extra interface{}
-}
-
func NewSqlStore() Store {
sqlStore := &SqlStore{}
@@ -464,18 +455,18 @@ func IsUniqueConstraintError(err string, mysql string, postgres string) bool {
return unique && field
}
-func (ss SqlStore) GetColumnInformation(tableName, columnName string) Column {
- var col Column
- err := ss.GetMaster().SelectOne(&col, "SHOW COLUMNS FROM "+tableName+" WHERE Field = :Columnname", map[string]interface{}{
+func (ss SqlStore) GetColumnDataType(tableName, columnName string) string {
+ dataType, err := ss.GetMaster().SelectStr("SELECT data_type FROM INFORMATION_SCHEMA.COLUMNS where table_name = :Tablename AND column_name = :Columnname", map[string]interface{}{
+ "Tablename": tableName,
"Columnname": columnName,
})
if err != nil {
- l4g.Critical("Failed to get information for column %s from table %s: %v", tableName, columnName, err.Error())
+ l4g.Critical("Failed to get data type for column %s from table %s: %v", tableName, columnName, err.Error())
time.Sleep(time.Second)
- panic("Failed to get information for column " + tableName + " from table " + columnName + ": " + err.Error())
+ panic("Failed to get get data type for column " + tableName + " from table " + columnName + ": " + err.Error())
}
- return col
+ return dataType
}
func (ss SqlStore) GetMaster() *gorp.DbMap {