Signed-off-by: 商讯在线 <swhbox@foxmail.com>
This commit is contained in:
商讯在线 2014-08-24 21:15:16 +08:00
parent 64790ba262
commit 34e79e0d63
5 changed files with 9 additions and 7 deletions

View File

@ -373,12 +373,14 @@ func (engine *Engine) DumpAll(w io.Writer) error {
} else if col.SQLType.IsText() || col.SQLType.IsTime() {
var v = fmt.Sprintf("%s", d)
temp += ", '" + strings.Replace(v, "'", "''", -1) + "'"
} else if col.SQLType.IsBlob() /**/ {
} else if col.SQLType.IsBlob() {
if reflect.TypeOf(d).Kind() == reflect.Slice {
temp += fmt.Sprintf(", %s", engine.dialect.FormatBytes(d.([]byte)))
} else if reflect.TypeOf(d).Kind() == reflect.String {
temp += fmt.Sprintf(", '%s'", d.(string))
}
} else if col.SQLType.IsNumeric() {
temp += fmt.Sprintf(", %s", string(d.([]byte)))
} else {
s := fmt.Sprintf("%v", d)
if strings.Contains(s, ":") || strings.Contains(s, "-") {

View File

@ -168,7 +168,7 @@ where a.object_id=object_id('` + tableName + `')`
}
}
if col.SQLType.IsText() {
if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.Default != "" {
col.Default = "'" + col.Default + "'"
} else {

View File

@ -60,7 +60,7 @@ func (db *mysql) SqlType(c *core.Column) string {
for v, _ := range c.EnumOptions {
opts += fmt.Sprintf(",'%v'", v)
}
res += strings.TrimLeft(opts,",")
res += strings.TrimLeft(opts, ",")
res += ")"
case core.Set: //mysql set
res = core.Set
@ -69,7 +69,7 @@ func (db *mysql) SqlType(c *core.Column) string {
for v, _ := range c.SetOptions {
opts += fmt.Sprintf(",'%v'", v)
}
res += strings.TrimLeft(opts,",")
res += strings.TrimLeft(opts, ",")
res += ")"
default:
res = t
@ -223,7 +223,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
col.IsAutoIncrement = true
}
if col.SQLType.IsText() {
if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.Default != "" {
col.Default = "'" + col.Default + "'"
} else {

View File

@ -158,7 +158,7 @@ func (db *oracle) GetColumns(tableName string) ([]string, map[string]*core.Colum
col.Length = dataLen
if col.SQLType.IsText() {
if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.Default != "" {
col.Default = "'" + col.Default + "'"
} else {

View File

@ -220,7 +220,7 @@ WHERE c.relkind = 'r'::char AND c.relname = $1 AND f.attnum > 0 ORDER BY f.attnu
col.Length = maxLen
if col.SQLType.IsText() {
if col.SQLType.IsText() || col.SQLType.IsTime() {
if col.Default != "" {
col.Default = "'" + col.Default + "'"
} else {