aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/xorm.io/xorm/dialects/mssql.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/xorm.io/xorm/dialects/mssql.go')
-rw-r--r--vendor/xorm.io/xorm/dialects/mssql.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/xorm.io/xorm/dialects/mssql.go b/vendor/xorm.io/xorm/dialects/mssql.go
index f766950ca2..d76a8c6c11 100644
--- a/vendor/xorm.io/xorm/dialects/mssql.go
+++ b/vendor/xorm.io/xorm/dialects/mssql.go
@@ -214,6 +214,8 @@ var (
type mssql struct {
Base
+ defaultVarchar string
+ defaultChar string
}
func (db *mssql) Init(uri *URI) error {
@@ -221,6 +223,34 @@ func (db *mssql) Init(uri *URI) error {
return db.Base.Init(db, uri)
}
+func (db *mssql) SetParams(params map[string]string) {
+ defaultVarchar, ok := params["DEFAULT_VARCHAR"]
+ if ok {
+ var t = strings.ToUpper(defaultVarchar)
+ switch t {
+ case "NVARCHAR", "VARCHAR":
+ db.defaultVarchar = defaultVarchar
+ default:
+ db.defaultVarchar = "VARCHAR"
+ }
+ } else {
+ db.defaultVarchar = "VARCHAR"
+ }
+
+ defaultChar, ok := params["DEFAULT_CHAR"]
+ if ok {
+ var t = strings.ToUpper(defaultChar)
+ switch t {
+ case "NCHAR", "CHAR":
+ db.defaultChar = defaultChar
+ default:
+ db.defaultChar = "CHAR"
+ }
+ } else {
+ db.defaultChar = "CHAR"
+ }
+}
+
func (db *mssql) SQLType(c *schemas.Column) string {
var res string
switch t := c.SQLType.Name; t {
@@ -267,6 +297,10 @@ func (db *mssql) SQLType(c *schemas.Column) string {
case schemas.BigInt:
res = schemas.BigInt
c.Length = 0
+ case schemas.Varchar:
+ res = db.defaultVarchar
+ case schemas.Char:
+ res = db.defaultChar
default:
res = t
}