Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 22 for berate (0.25 sec)

  1. tests/create_test.go

    func TestCreateFromMap(t *testing.T) {
    	if err := DB.Model(&User{}).Create(map[string]interface{}{"Name": "create_from_map", "Age": 18}).Error; err != nil {
    		t.Fatalf("failed to create data from map, got error: %v", err)
    	}
    
    	var result User
    	if err := DB.Where("name = ?", "create_from_map").First(&result).Error; err != nil || result.Age != 18 {
    		t.Fatalf("failed to create from map, got error %v", err)
    	}
    
    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/associations_has_many_test.go

    import (
    	"testing"
    
    	"gorm.io/gorm"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestHasManyAssociation(t *testing.T) {
    	user := *GetUser("hasmany", Config{Pets: 2})
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	CheckUser(t, user, user)
    
    	// Find
    	var user2 User
    	DB.Find(&user2, "id = ?", user.ID)
    	DB.Model(&user2).Association("Pets").Find(&user2.Pets)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  3. tests/joins_test.go

    		return
    	}
    }
    
    func TestJoinCount(t *testing.T) {
    	companyA := Company{Name: "A"}
    	companyB := Company{Name: "B"}
    	DB.Create(&companyA)
    	DB.Create(&companyB)
    
    	user := User{Name: "kingGo", CompanyID: &companyB.ID}
    	DB.Create(&user)
    
    	query := DB.Model(&User{}).Joins("Company")
    	// Bug happens when .Count is called on a query.
    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)
  4. callbacks/create.go

    				if i, ok := value.(BeforeCreateInterface); ok {
    					called = true
    					db.AddError(i.BeforeCreate(tx))
    				}
    			}
    			return called
    		})
    	}
    }
    
    // Create create hook
    func Create(config *Config) func(db *gorm.DB) {
    	supportReturning := utils.Contains(config.CreateClauses, "RETURNING")
    
    	return func(db *gorm.DB) {
    		if db.Error != nil {
    			return
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 08 03:29:55 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  5. tests/upsert_test.go

    		t.Errorf("user should be created with search value")
    	}
    
    	DB.FirstOrCreate(&user3, map[string]interface{}{"name": "find or create 2"})
    	if user3.Name != "find or create 2" || user3.ID == 0 {
    		t.Errorf("user should be created with inline search value")
    	}
    
    	DB.Where(&User{Name: "find or create 3"}).Attrs("age", 44).FirstOrCreate(&user4)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  6. tests/hooks_test.go

    		t.Fatalf("An error from before create callbacks happened when create with invalid value")
    	}
    
    	if DB.Where("code = ?", "Invalid").First(&Product{}).Error == nil {
    		t.Fatalf("Should not save record that have errors")
    	}
    
    	if DB.Save(&Product{Code: "dont_save", Price: 100}).Error == nil {
    		t.Fatalf("An error from after create callbacks happened when create with invalid value")
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  7. callbacks/associations.go

    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    func SaveBeforeAssociations(create bool) func(db *gorm.DB) {
    	return func(db *gorm.DB) {
    		if db.Error == nil && db.Statement.Schema != nil {
    			selectColumns, restricted := db.Statement.SelectAndOmitColumns(create, !create)
    
    			// Save Belongs To associations
    			for _, rel := range db.Statement.Schema.Relationships.BelongsTo {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Apr 11 03:06:13 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  8. migrator/migrator.go

    	})
    
    	return columnTypes, execErr
    }
    
    // CreateView create view from Query in gorm.ViewOption.
    // Query in gorm.ViewOption is a [subquery]
    //
    //	// CREATE VIEW `user_view` AS SELECT * FROM `users` WHERE age > 20
    //	q := DB.Model(&User{}).Where("age > ?", 20)
    //	DB.Debug().Migrator().CreateView("user_view", gorm.ViewOption{Query: q})
    //
    //	// CREATE OR REPLACE VIEW `users_view` AS SELECT * FROM `users` WITH CHECK OPTION
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  9. tests/preload_suits_test.go

    		t.Error(err)
    	}
    
    	want := make([]Level3, 2)
    	want[0] = Level3{Level2: Level2{Level1: Level1{Value: "value"}}}
    	if err := DB.Create(&want[0]).Error; err != nil {
    		t.Error(err)
    	}
    	want[1] = Level3{Level2: Level2{Level1: Level1{Value: "value2"}}}
    	if err := DB.Create(&want[1]).Error; err != nil {
    		t.Error(err)
    	}
    
    	var got []Level3
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Mar 18 05:38:46 GMT 2022
    - 30.3K bytes
    - Viewed (0)
  10. finisher_api.go

    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // Create inserts value, returning the inserted data's primary key in value's id
    func (db *DB) Create(value interface{}) (tx *DB) {
    	if db.CreateBatchSize > 0 {
    		return db.CreateInBatches(value, db.CreateBatchSize)
    	}
    
    	tx = db.getInstance()
    	tx.Statement.Dest = value
    	return tx.callbacks.Create().Execute(tx)
    }
    
    // CreateInBatches inserts value in batches of batchSize
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
Back to top