Browse Source

Implementing elseif for conversion of Default

Before this commit the Default would be reset to 0 every time it is not true. This results in an issue when true is converted to 1 and 1 is not true, resulting in a conversion to 0.
xormplus 7 years ago
parent
commit
da46657160
1 changed files with 4 additions and 4 deletions
  1. 4 4
      dialect_mssql.go

+ 4 - 4
dialect_mssql.go

@@ -218,7 +218,7 @@ func (db *mssql) SqlType(c *core.Column) string {
 		res = core.Bit
 		if strings.EqualFold(c.Default, "true") {
 			c.Default = "1"
-		} else {
+		} else if strings.EqualFold(c.Default, "false") {
 			c.Default = "0"
 		}
 	case core.Serial:
@@ -340,12 +340,12 @@ func (db *mssql) GetColumns(tableName string) ([]string, map[string]*core.Column
 	s := `select a.name as name, b.name as ctype,a.max_length,a.precision,a.scale,a.is_nullable as nullable,
 	      replace(replace(isnull(c.text,''),'(',''),')','') as vdefault,
 		  ISNULL(i.is_primary_key, 0)
-          from sys.columns a
+          from sys.columns a 
 		  left join sys.types b on a.user_type_id=b.user_type_id
           left join sys.syscomments c on a.default_object_id=c.id
-		  LEFT OUTER JOIN
+		  LEFT OUTER JOIN 
     sys.index_columns ic ON ic.object_id = a.object_id AND ic.column_id = a.column_id
-		  LEFT OUTER JOIN
+		  LEFT OUTER JOIN 
     sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
           where a.object_id=object_id('` + tableName + `')`
 	db.LogSQL(s, args)