|
|
@ -229,7 +229,7 @@ func (db *mssql) SetParams(params map[string]string) { |
|
|
|
var t = strings.ToUpper(defaultVarchar) |
|
|
|
var t = strings.ToUpper(defaultVarchar) |
|
|
|
switch t { |
|
|
|
switch t { |
|
|
|
case "NVARCHAR", "VARCHAR": |
|
|
|
case "NVARCHAR", "VARCHAR": |
|
|
|
db.defaultVarchar = defaultVarchar |
|
|
|
db.defaultVarchar = t |
|
|
|
default: |
|
|
|
default: |
|
|
|
db.defaultVarchar = "VARCHAR" |
|
|
|
db.defaultVarchar = "VARCHAR" |
|
|
|
} |
|
|
|
} |
|
|
@ -242,7 +242,7 @@ func (db *mssql) SetParams(params map[string]string) { |
|
|
|
var t = strings.ToUpper(defaultChar) |
|
|
|
var t = strings.ToUpper(defaultChar) |
|
|
|
switch t { |
|
|
|
switch t { |
|
|
|
case "NCHAR", "CHAR": |
|
|
|
case "NCHAR", "CHAR": |
|
|
|
db.defaultChar = defaultChar |
|
|
|
db.defaultChar = t |
|
|
|
default: |
|
|
|
default: |
|
|
|
db.defaultChar = "CHAR" |
|
|
|
db.defaultChar = "CHAR" |
|
|
|
} |
|
|
|
} |
|
|
@ -285,7 +285,7 @@ func (db *mssql) SQLType(c *schemas.Column) string { |
|
|
|
case schemas.MediumInt: |
|
|
|
case schemas.MediumInt: |
|
|
|
res = schemas.Int |
|
|
|
res = schemas.Int |
|
|
|
case schemas.Text, schemas.MediumText, schemas.TinyText, schemas.LongText, schemas.Json: |
|
|
|
case schemas.Text, schemas.MediumText, schemas.TinyText, schemas.LongText, schemas.Json: |
|
|
|
res = schemas.Varchar + "(MAX)" |
|
|
|
res = db.defaultVarchar + "(MAX)" |
|
|
|
case schemas.Double: |
|
|
|
case schemas.Double: |
|
|
|
res = schemas.Real |
|
|
|
res = schemas.Real |
|
|
|
case schemas.Uuid: |
|
|
|
case schemas.Uuid: |
|
|
@ -297,10 +297,26 @@ func (db *mssql) SQLType(c *schemas.Column) string { |
|
|
|
case schemas.BigInt: |
|
|
|
case schemas.BigInt: |
|
|
|
res = schemas.BigInt |
|
|
|
res = schemas.BigInt |
|
|
|
c.Length = 0 |
|
|
|
c.Length = 0 |
|
|
|
|
|
|
|
case schemas.NVarchar: |
|
|
|
|
|
|
|
res = t |
|
|
|
|
|
|
|
if c.Length == -1 { |
|
|
|
|
|
|
|
res += "(MAX)" |
|
|
|
|
|
|
|
} |
|
|
|
case schemas.Varchar: |
|
|
|
case schemas.Varchar: |
|
|
|
res = db.defaultVarchar |
|
|
|
res = db.defaultVarchar |
|
|
|
|
|
|
|
if c.Length == -1 { |
|
|
|
|
|
|
|
res += "(MAX)" |
|
|
|
|
|
|
|
} |
|
|
|
case schemas.Char: |
|
|
|
case schemas.Char: |
|
|
|
res = db.defaultChar |
|
|
|
res = db.defaultChar |
|
|
|
|
|
|
|
if c.Length == -1 { |
|
|
|
|
|
|
|
res += "(MAX)" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case schemas.NChar: |
|
|
|
|
|
|
|
res = t |
|
|
|
|
|
|
|
if c.Length == -1 { |
|
|
|
|
|
|
|
res += "(MAX)" |
|
|
|
|
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
|
res = t |
|
|
|
res = t |
|
|
|
} |
|
|
|
} |
|
|
@ -424,8 +440,18 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.TimeStampz, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.TimeStampz, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
case "NVARCHAR": |
|
|
|
case "NVARCHAR": |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.NVarchar, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.NVarchar, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
|
|
|
|
if col.Length > 0 { |
|
|
|
|
|
|
|
col.Length /= 2 |
|
|
|
|
|
|
|
col.Length2 /= 2 |
|
|
|
|
|
|
|
} |
|
|
|
case "IMAGE": |
|
|
|
case "IMAGE": |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.VarBinary, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
col.SQLType = schemas.SQLType{Name: schemas.VarBinary, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
|
|
|
|
case "NCHAR": |
|
|
|
|
|
|
|
if col.Length > 0 { |
|
|
|
|
|
|
|
col.Length /= 2 |
|
|
|
|
|
|
|
col.Length2 /= 2 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fallthrough |
|
|
|
default: |
|
|
|
default: |
|
|
|
if _, ok := schemas.SqlTypes[ct]; ok { |
|
|
|
if _, ok := schemas.SqlTypes[ct]; ok { |
|
|
|
col.SQLType = schemas.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0} |
|
|
|
col.SQLType = schemas.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0} |
|
|
|