Commit ad905139 authored by Faizal Aziz's avatar Faizal Aziz

fixing constraint

parent a1fd7bf5
...@@ -345,6 +345,9 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin ...@@ -345,6 +345,9 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin
} }
argName := field.Tag.Get("sql-constraint") argName := field.Tag.Get("sql-constraint")
if argName != "" {
argName = "constraint " + argName
}
keysName := field.Tag.Get("sql-keys") keysName := field.Tag.Get("sql-keys")
if keysName == "" { if keysName == "" {
...@@ -356,7 +359,7 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin ...@@ -356,7 +359,7 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin
argName = val argName = val
} }
} }
argName = fmt.Sprintf("%s_%s", keysName, argName) argName = fmt.Sprintf("constraint %s_%s", keysName, argName)
} }
} }
...@@ -365,5 +368,5 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin ...@@ -365,5 +368,5 @@ func generateSQLFromStorage(tableName string, columnAndValues interface{}) strin
columnNamesStr := strings.Replace(strings.TrimRight(columnNames, ","), "DROP DATABASE", "", 1) columnNamesStr := strings.Replace(strings.TrimRight(columnNames, ","), "DROP DATABASE", "", 1)
return fmt.Sprintf("'CREATE TABLE IF NOT EXISTS %s (%s)'", tableName, columnNamesStr) return fmt.Sprintf("CREATE TABLE IF NOT EXISTS %s (%s);", tableName, columnNamesStr)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment