mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Fix label count (#8267)
* fix label count * fix vendor * fix import order * update xorm to fix bug * fix tests * fix mssql bug
This commit is contained in:
		
							
								
								
									
										58
									
								
								vendor/xorm.io/builder/builder_insert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								vendor/xorm.io/builder/builder_insert.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -7,6 +7,7 @@ package builder | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"sort" | ||||
| ) | ||||
|  | ||||
| // Insert creates an insert Builder | ||||
| @@ -87,3 +88,60 @@ func (b *Builder) insertWriteTo(w Writer) error { | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type insertColsSorter struct { | ||||
| 	cols []string | ||||
| 	vals []interface{} | ||||
| } | ||||
|  | ||||
| func (s insertColsSorter) Len() int { | ||||
| 	return len(s.cols) | ||||
| } | ||||
|  | ||||
| func (s insertColsSorter) Swap(i, j int) { | ||||
| 	s.cols[i], s.cols[j] = s.cols[j], s.cols[i] | ||||
| 	s.vals[i], s.vals[j] = s.vals[j], s.vals[i] | ||||
| } | ||||
|  | ||||
| func (s insertColsSorter) Less(i, j int) bool { | ||||
| 	return s.cols[i] < s.cols[j] | ||||
| } | ||||
|  | ||||
| // Insert sets insert SQL | ||||
| func (b *Builder) Insert(eq ...interface{}) *Builder { | ||||
| 	if len(eq) > 0 { | ||||
| 		var paramType = -1 | ||||
| 		for _, e := range eq { | ||||
| 			switch t := e.(type) { | ||||
| 			case Eq: | ||||
| 				if paramType == -1 { | ||||
| 					paramType = 0 | ||||
| 				} | ||||
| 				if paramType != 0 { | ||||
| 					break | ||||
| 				} | ||||
| 				for k, v := range t { | ||||
| 					b.insertCols = append(b.insertCols, k) | ||||
| 					b.insertVals = append(b.insertVals, v) | ||||
| 				} | ||||
| 			case string: | ||||
| 				if paramType == -1 { | ||||
| 					paramType = 1 | ||||
| 				} | ||||
| 				if paramType != 1 { | ||||
| 					break | ||||
| 				} | ||||
| 				b.insertCols = append(b.insertCols, t) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(b.insertCols) == len(b.insertVals) { | ||||
| 		sort.Sort(insertColsSorter{ | ||||
| 			cols: b.insertCols, | ||||
| 			vals: b.insertVals, | ||||
| 		}) | ||||
| 	} | ||||
| 	b.optype = insertType | ||||
| 	return b | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user