Merge bd0aed633e55d65cb00f02c75a1891574fd887ac into 9acaa33324bbcc78239a1c913d4f1292c12177b9
This commit is contained in:
		
						commit
						6dc31d2bf1
					
				
							
								
								
									
										21
									
								
								main_test.go
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								main_test.go
									
									
									
									
									
								
							@ -100,6 +100,27 @@ func TestStringPrimaryKey(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type UUIDStruct struct {
 | 
				
			||||||
 | 
						ID   string `gorm:"primary_key"`
 | 
				
			||||||
 | 
						Name string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (u *UUIDStruct) BeforeSave() {
 | 
				
			||||||
 | 
						u.ID = "new_uuid"
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestBeforeSaveGenerateId(t *testing.T) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DB.DropTable(&UUIDStruct{})
 | 
				
			||||||
 | 
						DB.AutoMigrate(&UUIDStruct{})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						data := UUIDStruct{}
 | 
				
			||||||
 | 
						if err := DB.Save(&data).Error; err != nil || data.ID != "new_uuid" {
 | 
				
			||||||
 | 
							t.Errorf("string primary key should be changed")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestExceptionsWithInvalidSql(t *testing.T) {
 | 
					func TestExceptionsWithInvalidSql(t *testing.T) {
 | 
				
			||||||
	var columns []string
 | 
						var columns []string
 | 
				
			||||||
	if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
 | 
						if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user