Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for TestFirstOrCreateWithPrimaryKey (0.22 sec)

  1. tests/create_test.go

    	company := Company{Name: "first_or_create_if_not_exists_table"}
    	if err := DB.Table("not_exists").FirstOrCreate(&company).Error; err == nil {
    		t.Errorf("not exists table, but err is nil")
    	}
    }
    
    func TestFirstOrCreateWithPrimaryKey(t *testing.T) {
    	company := Company{ID: 100, Name: "company100_with_primarykey"}
    	DB.FirstOrCreate(&company)
    
    	if company.ID != 100 {
    		t.Errorf("invalid primary key after creating, got %v", company.ID)
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Mon Jul 21 09:55:20 UTC 2025
    - 26.8K bytes
    - Viewed (0)
Back to top