Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 15 for Hill (0.16 sec)

  1. tests/create_test.go

    	if result.RowsAffected != int64(len(users)) {
    		t.Errorf("affected rows should be %v, but got %v", len(users), result.RowsAffected)
    	}
    
    	for _, user := range users {
    		if user.ID == 0 {
    			t.Fatalf("failed to fill user's ID, got %v", user.ID)
    		} else {
    			var newUser User
    			if err := DB.Where("id = ?", user.ID).Preload(clause.Associations).First(&newUser).Error; err != nil {
    				t.Fatalf("errors happened when query: %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/joins_test.go

    	DB.Create(&user)
    
    	query := DB.Model(&User{}).Joins("Company")
    	// Bug happens when .Count is called on a query.
    	// 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
    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)
  3. chainable_api.go

    )
    
    // Model specify the model you would like to run db operations
    //
    //	// update all users's name to `hello`
    //	db.Model(&User{}).Update("name", "hello")
    //	// if user's primary key is non-blank, will use it as condition, then will only update that user's name to `hello`
    //	db.Model(&user).Update("name", "hello")
    func (db *DB) Model(value interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Model = value
    	return
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  4. tests/hooks_test.go

    		if products[idx].Price != value {
    			t.Errorf("invalid price for product #%v, expects: %v, got %v", idx, value, products[idx].Price)
    		}
    	}
    
    	DB.Model(&products).Update("Name", "product-name")
    
    	// will set all product's price to last product's price + 10
    	for idx, value := range []int64{410, 410, 410} {
    		if products[idx].Price != 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)
  5. tests/main_test.go

    package tests_test
    
    import (
    	"testing"
    
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestExceptionsWithInvalidSql(t *testing.T) {
    	if name := DB.Dialector.Name(); name == "sqlserver" {
    		t.Skip("skip sqlserver due to it will raise data race for invalid sql")
    	}
    
    	var columns []string
    	if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
    		t.Errorf("Should got error with invalid SQL")
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 24 01:31:58 GMT 2022
    - 1.4K bytes
    - Viewed (0)
  6. tests/gorm_test.go

    	dialect := DB.Dialector.Name()
    	switch dialect {
    	case "mysql", "sqlserver":
    		// these dialects do not support the "returning" clause
    		return
    	default:
    		// This user struct will leverage the existing users table, but override
    		// the Name field to default to null.
    		type user struct {
    			gorm.Model
    			Name string `gorm:"default:null"`
    		}
    		u1 := user{}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jun 01 07:22:21 GMT 2023
    - 3.3K bytes
    - Viewed (0)
  7. logger/logger.go

    	Warn(context.Context, string, ...interface{})
    	Error(context.Context, string, ...interface{})
    	Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)
    }
    
    var (
    	// Discard logger will print any log to io.Discard
    	Discard = New(log.New(io.Discard, "", log.LstdFlags), Config{})
    	// Default Default logger
    	Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), Config{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Nov 07 02:19:41 GMT 2023
    - 5.8K bytes
    - Viewed (0)
  8. finisher_api.go

    	return
    }
    
    // FirstOrCreate finds the first matching record, otherwise if not found creates a new instance with given conds.
    // Each conds must be a struct or map.
    //
    // Using FirstOrCreate in conjunction with Assign will result in an update to the database even if the record exists.
    //
    //	// assign an email if the record is not found
    //	result := db.Where(User{Name: "non_existing"}).Attrs(User{Email: "******@****.***"}).FirstOrCreate(&user)
    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)
  9. tests/migrate_test.go

    			}
    			test.checkFunc(t)
    		})
    	}
    
    	if DB.Dialector.Name() != "sqlserver" {
    		// In SQLServer, If an index or constraint depends on the column,
    		// this column will not be able to run ALTER
    		// see https://stackoverflow.com/questions/19460912/the-object-df-is-dependent-on-column-changing-int-to-double/19461205#19461205
    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)
  10. tests/transaction_test.go

    			t.Fatalf("Should find saved record")
    		}
    
    		return errors.New("the error message")
    	})
    
    	if err != nil && err.Error() != "the error message" {
    		t.Fatalf("Transaction return error will equal the block returns error")
    	}
    
    	if err := DB.First(&User{}, "name = ?", "transaction-block").Error; err == nil {
    		t.Fatalf("Should not find record after rollback")
    	}
    
    	// commit
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
Back to top