aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/xorm.io/xorm/dialects/mssql.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-17 01:53:28 +0800
committerGitHub <noreply@github.com>2021-09-16 13:53:28 -0400
commite21a35698c7df61949d33888c08a483e5ce61abf (patch)
tree46b758b5b1ef70f2a82bdb058ad25fed118156b5 /vendor/xorm.io/xorm/dialects/mssql.go
parent8de44d1995e73ec139ede5626466af1fce8c571a (diff)
downloadgitea-e21a35698c7df61949d33888c08a483e5ce61abf.tar.gz
gitea-e21a35698c7df61949d33888c08a483e5ce61abf.zip
Upgrade xorm to v1.2.4 (#17059) (#17068)
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'vendor/xorm.io/xorm/dialects/mssql.go')
-rw-r--r--vendor/xorm.io/xorm/dialects/mssql.go39
1 files changed, 21 insertions, 18 deletions
diff --git a/vendor/xorm.io/xorm/dialects/mssql.go b/vendor/xorm.io/xorm/dialects/mssql.go
index 2121e71dd3..ab010eb02a 100644
--- a/vendor/xorm.io/xorm/dialects/mssql.go
+++ b/vendor/xorm.io/xorm/dialects/mssql.go
@@ -626,34 +626,37 @@ WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
}
func (db *mssql) CreateTableSQL(table *schemas.Table, tableName string) ([]string, bool) {
- var sql string
if tableName == "" {
tableName = table.Name
}
- sql = "IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = '" + tableName + "' ) CREATE TABLE "
+ quoter := db.dialect.Quoter()
+ var b strings.Builder
+ b.WriteString("IF NOT EXISTS (SELECT [name] FROM sys.tables WHERE [name] = '")
+ quoter.QuoteTo(&b, tableName)
+ b.WriteString("' ) CREATE TABLE ")
+ quoter.QuoteTo(&b, tableName)
+ b.WriteString(" (")
- sql += db.Quoter().Quote(tableName) + " ("
-
- pkList := table.PrimaryKeys
-
- for _, colName := range table.ColumnsSeq() {
+ for i, colName := range table.ColumnsSeq() {
col := table.GetColumn(colName)
- s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1)
- sql += s
- sql = strings.TrimSpace(sql)
- sql += ", "
+ s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1)
+ b.WriteString(s)
+
+ if i != len(table.ColumnsSeq())-1 {
+ b.WriteString(", ")
+ }
}
- if len(pkList) > 1 {
- sql += "PRIMARY KEY ( "
- sql += strings.Join(pkList, ",")
- sql += " ), "
+ if len(table.PrimaryKeys) > 1 {
+ b.WriteString(", PRIMARY KEY (")
+ b.WriteString(quoter.Join(table.PrimaryKeys, ","))
+ b.WriteString(")")
}
- sql = sql[:len(sql)-2] + ")"
- sql += ";"
- return []string{sql}, true
+ b.WriteString(")")
+
+ return []string{b.String()}, true
}
func (db *mssql) ForUpdateSQL(query string) string {