fix: ignore nil query (#6021)
This commit is contained in:
		
							parent
							
								
									4d6b70ec88
								
							
						
					
					
						commit
						e1f46eb802
					
				| @ -311,6 +311,9 @@ func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) [] | |||||||
| 	conds := make([]clause.Expression, 0, 4) | 	conds := make([]clause.Expression, 0, 4) | ||||||
| 	args = append([]interface{}{query}, args...) | 	args = append([]interface{}{query}, args...) | ||||||
| 	for idx, arg := range args { | 	for idx, arg := range args { | ||||||
|  | 		if arg == nil { | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
| 		if valuer, ok := arg.(driver.Valuer); ok { | 		if valuer, ok := arg.(driver.Valuer); ok { | ||||||
| 			arg, _ = valuer.Value() | 			arg, _ = valuer.Value() | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -35,6 +35,13 @@ func TestWhereCloneCorruption(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func TestNilCondition(t *testing.T) { | ||||||
|  | 	s := new(Statement) | ||||||
|  | 	if len(s.BuildCondition(nil)) != 0 { | ||||||
|  | 		t.Errorf("Nil condition should be empty") | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func TestNameMatcher(t *testing.T) { | func TestNameMatcher(t *testing.T) { | ||||||
| 	for k, v := range map[string][]string{ | 	for k, v := range map[string][]string{ | ||||||
| 		"table.name":         {"table", "name"}, | 		"table.name":         {"table", "name"}, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 chyroc
						chyroc