Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for an (0.12 sec)

  1. tests/hooks_test.go

    	if DB.Save(&p2).Error == nil {
    		t.Fatalf("An error from before save callbacks happened when update with invalid value")
    	}
    
    	p3 := Product{Code: "dont_delete", Price: 100}
    	DB.Save(&p3)
    	if DB.Delete(&p3).Error == nil {
    		t.Fatalf("An error from before delete callbacks happened when delete")
    	}
    
    	if DB.Where("Code = ?", "dont_delete").First(&p3).Error != nil {
    		t.Fatalf("An error from before delete callbacks happened")
    	}
    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)
  2. chainable_api.go

    //
    // Attrs only adds attributes if the record is not found.
    //
    //	// assign an email if the record is not found
    //	db.Where(User{Name: "non_existing"}).Attrs(User{Email: "******@****.***"}).FirstOrInit(&user)
    //	// user -> User{Name: "non_existing", Email: "******@****.***"}
    //
    //	// assign an email if the record is not found, otherwise ignore provided email
    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)
  3. finisher_api.go

    // 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)
  4. migrator/column_type.go

    func (ct ColumnType) Name() string {
    	if ct.NameValue.Valid {
    		return ct.NameValue.String
    	}
    	return ct.SQLColumnType.Name()
    }
    
    // DatabaseTypeName returns the database system name of the column type. If an empty
    // string is returned, then the driver type name is not supported.
    // Consult your driver documentation for a list of driver data types. Length specifiers
    // are not included.
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 24 01:31:58 GMT 2022
    - 3.3K bytes
    - Viewed (0)
  5. tests/customize_field_test.go

    	var cc2 CustomizeColumn
    	DB.First(&cc2, "mapped_id = ?", 666)
    	if cc2.Name != "bar" {
    		t.Errorf("Failed to query CustomizeColumn")
    	}
    }
    
    func TestCustomColumnAndIgnoredFieldClash(t *testing.T) {
    	// Make sure an ignored field does not interfere with another field's custom
    	// column name that matches the ignored field.
    	type CustomColumnAndIgnoredFieldClash struct {
    		Body    string `gorm:"-"`
    		RawBody string `gorm:"column:body"`
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Sep 11 09:33:31 GMT 2020
    - 6.9K bytes
    - Viewed (0)
  6. tests/migrate_test.go

    		t.Fatalf("Failed to auto migrate: error: %v", err)
    	}
    
    	// make new session to set custom logger tracer
    	session := DB.Session(&gorm.Session{Logger: tracer})
    
    	// The second AutoMigrate to catch an error
    	if err := session.AutoMigrate(&MigrateInt{}); err != nil {
    		t.Fatalf("Failed to auto migrate: error: %v", err)
    	}
    }
    
    func TestAutoMigrateSelfReferential(t *testing.T) {
    	type MigratePerson struct {
    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)
  7. tests/update_test.go

    		Where("id = ?", elem.Id).
    		Updates(&ElementWithIgnoredField{Value: "bar", IgnoredField: 100})
    
    	var result ElementWithIgnoredField
    	if err := DB.First(&result, elem.Id).Error; err != nil {
    		t.Errorf("error getting an element from database: %s", err.Error())
    	}
    
    	if result.IgnoredField != 0 {
    		t.Errorf("element's ignored field should not be updated")
    	}
    }
    
    func TestUpdateFromSubQuery(t *testing.T) {
    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)
Back to top