Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 20 for companies (0.5 sec)

  1. tests/create_test.go

    	}
    
    	companies := []Company{
    		{ID: 101, Name: "company101_with_primarykey"},
    		{ID: 102, Name: "company102_with_primarykey"},
    	}
    	DB.Create(&companies)
    
    	if companies[0].ID != 101 || companies[1].ID != 102 {
    		t.Errorf("invalid primary key after creating, got %v, %v", companies[0].ID, companies[1].ID)
    	}
    }
    
    func TestCreateFromSubQuery(t *testing.T) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  2. tests/count_test.go

    		t.Fatalf("Build count with select, but got %v", result.Statement.SQL.String())
    	}
    
    	var count4 int64
    	if err := DB.Table("users").Joins("LEFT JOIN companies on companies.name = users.name").Where("users.name = ?", user1.Name).Count(&count4).Error; err != nil || count4 != 1 {
    		t.Errorf("count with join, got error: %v, count %v", err, count4)
    	}
    
    	var count5 int64
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  3. tests/postgres_test.go

    	}
    }
    
    type CompanyNew struct {
    	ID   int
    	Name int
    }
    
    func TestAlterColumnDataType(t *testing.T) {
    	DB.AutoMigrate(Company{})
    
    	if err := DB.Table("companies").Migrator().AlterColumn(CompanyNew{}, "name"); err != nil {
    		t.Fatalf("failed to alter column from string to int, got error %v", err)
    	}
    
    	DB.AutoMigrate(Company{})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Oct 08 09:16:32 GMT 2022
    - 6.4K bytes
    - Viewed (3)
  4. clause/from_test.go

    							},
    						}, {
    							Type:  clause.LeftJoin,
    							Table: clause.Table{Name: "companies"},
    							Using: []string{"company_name"},
    						},
    					},
    				},
    			},
    			"SELECT * FROM `users` INNER JOIN `articles` ON `articles`.`id` = `users`.`id` LEFT JOIN `companies` USING (`company_name`)", nil,
    		},
    	}
    
    	for idx, result := range results {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jul 15 02:25:10 GMT 2020
    - 1.9K bytes
    - Viewed (0)
  5. tests/delete_test.go

    		return
    	}
    
    	companies := []Company{
    		{Name: "delete-returning-1"},
    		{Name: "delete-returning-2"},
    		{Name: "delete-returning-3"},
    	}
    	DB.Create(&companies)
    
    	var results []Company
    	DB.Where("name IN ?", []string{companies[0].Name, companies[1].Name}).Clauses(clause.Returning{}).Delete(&results)
    	if len(results) != 2 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  6. tests/associations_belongs_to_test.go

    	AssertAssociationCount(t, users, "Company", 3, "")
    	AssertAssociationCount(t, users, "Manager", 2, "")
    
    	// Find
    	var companies []Company
    	if DB.Model(&users).Association("Company").Find(&companies); len(companies) != 3 {
    		t.Errorf("companies count should be %v, but got %v", 3, len(companies))
    	}
    
    	var managers []User
    	if DB.Model(&users).Association("Manager").Find(&managers); len(managers) != 2 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
  7. tests/sql_builder_test.go

    			Joins: []clause.Join{
    				{
    					Table: clause.Table{Name: "companies", Raw: false},
    					ON: clause.Where{
    						Exprs: []clause.Expression{
    							clause.Eq{
    								Column: clause.Column{
    									Table: "users",
    									Name:  "company_id",
    								},
    								Value: clause.Column{
    									Table: "companies",
    									Name:  "id",
    								},
    							},
    						},
    					},
    				},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
  8. tests/joins_test.go

    	// Removing the below two lines or downgrading to gorm v1.20.12 will make this test pass.
    	var total int64
    	query.Count(&total)
    
    	var result User
    
    	// Incorrectly generates a 'SELECT *' query which causes companies.id to overwrite users.id
    	if err := query.First(&result, user.ID).Error; err != nil {
    		t.Fatalf("Failed, got error: %v", err)
    	}
    
    	if result.ID != user.ID {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  9. tests/update_test.go

    	}
    
    	DB.Model(&user.Company).Update("Name", "new company name")
    	if err := DB.Table("users").Where("1 = 1").Update("name", DB.Table("companies").Select("name").Where("companies.id = users.company_id")).Error; err != nil {
    		t.Errorf("failed to update with sub query, got error %v", err)
    	}
    
    	DB.First(&result, user.ID)
    	if result.Name != "new company name" {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  10. tests/migrate_test.go

    	}
    
    	if tables, err := DB.Migrator().GetTables(); err != nil {
    		t.Fatalf("Failed to get database all tables, but got error %v", err)
    	} else {
    		for _, t1 := range []string{"users", "accounts", "pets", "companies", "toys", "languages", "tools"} {
    			hasTable := false
    			for _, t2 := range tables {
    				if t2 == t1 {
    					hasTable = true
    					break
    				}
    			}
    			if !hasTable {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top