correct generated sql
This commit is contained in:
		
							parent
							
								
									c70c097e88
								
							
						
					
					
						commit
						aceb3dad3b
					
				| @ -37,6 +37,9 @@ func (expr Expr) Build(builder Builder) { | ||||
| 				} else { | ||||
| 					switch rv := reflect.ValueOf(expr.Vars[idx]); rv.Kind() { | ||||
| 					case reflect.Slice, reflect.Array: | ||||
| 						if rv.Len() == 0 { | ||||
| 							builder.AddVar(builder, nil) | ||||
| 						} | ||||
| 						for i := 0; i < rv.Len(); i++ { | ||||
| 							if i > 0 { | ||||
| 								builder.WriteByte(',') | ||||
|  | ||||
| @ -202,6 +202,22 @@ func TestFind(t *testing.T) { | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| 
 | ||||
| 	var models []User | ||||
| 	if err := DB.Where("name in ?", []string{"find"}).Find(&models).Error; err != nil || len(models) != 3 { | ||||
| 		t.Errorf("errors happened when query find with in clause: %v, length: %v", err, len(models)) | ||||
| 	} else { | ||||
| 		for idx, user := range users { | ||||
| 			t.Run("FindWithInClause#"+strconv.Itoa(idx+1), func(t *testing.T) { | ||||
| 				CheckUser(t, models[idx], user) | ||||
| 			}) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	var none []User | ||||
| 	if err := DB.Where("name in ?", []string{}).Find(&none).Error; err != nil || len(none) != 0 { | ||||
| 		t.Errorf("errors happened when query find with in clause and zero length parameter: %v, length: %v", err, len(none)) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestQueryWithAssociation(t *testing.T) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 caelansar
						caelansar