修正依赖问题
This commit is contained in:
		
							
								
								
									
										6
									
								
								vendor/gorm.io/gorm/clause/limit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/gorm.io/gorm/clause/limit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +1,5 @@ | ||||
| package clause | ||||
|  | ||||
| import "strconv" | ||||
|  | ||||
| // Limit limit clause | ||||
| type Limit struct { | ||||
| 	Limit  *int | ||||
| @@ -17,14 +15,14 @@ func (limit Limit) Name() string { | ||||
| func (limit Limit) Build(builder Builder) { | ||||
| 	if limit.Limit != nil && *limit.Limit >= 0 { | ||||
| 		builder.WriteString("LIMIT ") | ||||
| 		builder.WriteString(strconv.Itoa(*limit.Limit)) | ||||
| 		builder.AddVar(builder, *limit.Limit) | ||||
| 	} | ||||
| 	if limit.Offset > 0 { | ||||
| 		if limit.Limit != nil && *limit.Limit >= 0 { | ||||
| 			builder.WriteByte(' ') | ||||
| 		} | ||||
| 		builder.WriteString("OFFSET ") | ||||
| 		builder.WriteString(strconv.Itoa(limit.Offset)) | ||||
| 		builder.AddVar(builder, limit.Offset) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/gorm.io/gorm/clause/locking.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/gorm.io/gorm/clause/locking.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,5 +1,12 @@ | ||||
| package clause | ||||
|  | ||||
| const ( | ||||
| 	LockingStrengthUpdate    = "UPDATE" | ||||
| 	LockingStrengthShare     = "SHARE" | ||||
| 	LockingOptionsSkipLocked = "SKIP LOCKED" | ||||
| 	LockingOptionsNoWait     = "NOWAIT" | ||||
| ) | ||||
|  | ||||
| type Locking struct { | ||||
| 	Strength string | ||||
| 	Table    Table | ||||
|   | ||||
							
								
								
									
										79
									
								
								vendor/gorm.io/gorm/clause/where.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										79
									
								
								vendor/gorm.io/gorm/clause/where.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,6 +21,12 @@ func (where Where) Name() string { | ||||
|  | ||||
| // Build build where clause | ||||
| func (where Where) Build(builder Builder) { | ||||
| 	if len(where.Exprs) == 1 { | ||||
| 		if andCondition, ok := where.Exprs[0].(AndConditions); ok { | ||||
| 			where.Exprs = andCondition.Exprs | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// Switch position if the first query expression is a single Or condition | ||||
| 	for idx, expr := range where.Exprs { | ||||
| 		if v, ok := expr.(OrConditions); !ok || len(v.Exprs) > 1 { | ||||
| @@ -147,6 +153,11 @@ func Not(exprs ...Expression) Expression { | ||||
| 	if len(exprs) == 0 { | ||||
| 		return nil | ||||
| 	} | ||||
| 	if len(exprs) == 1 { | ||||
| 		if andCondition, ok := exprs[0].(AndConditions); ok { | ||||
| 			exprs = andCondition.Exprs | ||||
| 		} | ||||
| 	} | ||||
| 	return NotConditions{Exprs: exprs} | ||||
| } | ||||
|  | ||||
| @@ -155,19 +166,63 @@ type NotConditions struct { | ||||
| } | ||||
|  | ||||
| func (not NotConditions) Build(builder Builder) { | ||||
| 	if len(not.Exprs) > 1 { | ||||
| 		builder.WriteByte('(') | ||||
| 	anyNegationBuilder := false | ||||
| 	for _, c := range not.Exprs { | ||||
| 		if _, ok := c.(NegationExpressionBuilder); ok { | ||||
| 			anyNegationBuilder = true | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for idx, c := range not.Exprs { | ||||
| 		if idx > 0 { | ||||
| 			builder.WriteString(AndWithSpace) | ||||
| 	if anyNegationBuilder { | ||||
| 		if len(not.Exprs) > 1 { | ||||
| 			builder.WriteByte('(') | ||||
| 		} | ||||
|  | ||||
| 		if negationBuilder, ok := c.(NegationExpressionBuilder); ok { | ||||
| 			negationBuilder.NegationBuild(builder) | ||||
| 		} else { | ||||
| 			builder.WriteString("NOT ") | ||||
| 		for idx, c := range not.Exprs { | ||||
| 			if idx > 0 { | ||||
| 				builder.WriteString(AndWithSpace) | ||||
| 			} | ||||
|  | ||||
| 			if negationBuilder, ok := c.(NegationExpressionBuilder); ok { | ||||
| 				negationBuilder.NegationBuild(builder) | ||||
| 			} else { | ||||
| 				builder.WriteString("NOT ") | ||||
| 				e, wrapInParentheses := c.(Expr) | ||||
| 				if wrapInParentheses { | ||||
| 					sql := strings.ToUpper(e.SQL) | ||||
| 					if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace); wrapInParentheses { | ||||
| 						builder.WriteByte('(') | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				c.Build(builder) | ||||
|  | ||||
| 				if wrapInParentheses { | ||||
| 					builder.WriteByte(')') | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if len(not.Exprs) > 1 { | ||||
| 			builder.WriteByte(')') | ||||
| 		} | ||||
| 	} else { | ||||
| 		builder.WriteString("NOT ") | ||||
| 		if len(not.Exprs) > 1 { | ||||
| 			builder.WriteByte('(') | ||||
| 		} | ||||
|  | ||||
| 		for idx, c := range not.Exprs { | ||||
| 			if idx > 0 { | ||||
| 				switch c.(type) { | ||||
| 				case OrConditions: | ||||
| 					builder.WriteString(OrWithSpace) | ||||
| 				default: | ||||
| 					builder.WriteString(AndWithSpace) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			e, wrapInParentheses := c.(Expr) | ||||
| 			if wrapInParentheses { | ||||
| 				sql := strings.ToUpper(e.SQL) | ||||
| @@ -182,9 +237,9 @@ func (not NotConditions) Build(builder Builder) { | ||||
| 				builder.WriteByte(')') | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if len(not.Exprs) > 1 { | ||||
| 		builder.WriteByte(')') | ||||
| 		if len(not.Exprs) > 1 { | ||||
| 			builder.WriteByte(')') | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user