Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for exists (0.16 sec)

  1. callbacks/preload.go

    		}
    
    		datas, ok := identityMap[utils.ToStringKey(fieldValues...)]
    		if !ok {
    			return fmt.Errorf("failed to assign association %#v, make sure foreign fields exists", elem.Interface())
    		}
    
    		for _, data := range datas {
    			reflectFieldValue := rel.Field.ReflectValueOf(tx.Statement.Context, data)
    			if reflectFieldValue.Kind() == reflect.Ptr && reflectFieldValue.IsNil() {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 11.3K bytes
    - Viewed (0)
  2. tests/associations_belongs_to_test.go

    		t.Errorf("Error happened when append company to user, got %v", err)
    	}
    
    	if users[0].CompanyID == nil || users[1].CompanyID == nil || *users[0].CompanyID != *users[1].CompanyID {
    		t.Errorf("user's company id should exists and equal, but its: %v, %v", users[0].CompanyID, users[1].CompanyID)
    	}
    
    	DB.Model(&users[0]).Association("Company").Delete(&company)
    	AssertAssociationCount(t, users[0], "Company", 0, "After Delete")
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
  3. statement.go

    	} else {
    		name := v.Name()
    		c := stmt.Clauses[name]
    		c.Name = name
    		v.MergeClause(&c)
    		stmt.Clauses[name] = c
    	}
    }
    
    // AddClauseIfNotExists add clause if not exists
    func (stmt *Statement) AddClauseIfNotExists(v clause.Interface) {
    	if c, ok := stmt.Clauses[v.Name()]; !ok || c.Expression == nil {
    		stmt.AddClause(v)
    	}
    }
    
    // BuildCondition build condition
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
  4. utils/utils_test.go

    		}
    	}
    }
    
    func TestContains(t *testing.T) {
    	containsTests := []struct {
    		name  string
    		elems []string
    		elem  string
    		out   bool
    	}{
    		{"exists", []string{"1", "2", "3"}, "1", true},
    		{"not exists", []string{"1", "2", "3"}, "4", false},
    	}
    	for _, test := range containsTests {
    		t.Run(test.name, func(t *testing.T) {
    			if out := Contains(test.elems, test.elem); test.out != out {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Feb 19 03:42:25 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  5. callbacks.go

    			return true
    		}
    		if cs[j].after == "*" && cs[i].after != "*" {
    			return true
    		}
    		return false
    	})
    
    	for _, c := range cs {
    		// show warning message the callback name already exists
    		if idx := getRIndex(names, c.name); idx > -1 && !c.replace && !c.remove && !cs[idx].remove {
    			c.processor.db.Logger.Warn(context.Background(), "duplicated callback `%s` from %s\n", c.name, utils.FileWithLineNum())
    		}
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Mar 26 03:33:36 GMT 2024
    - 8.6K bytes
    - Viewed (1)
  6. tests/preload_test.go

    	if len(user3.Pets) != 0 {
    		t.Fatalf("User.Pet[0] was deleted and should not exist.")
    	}
    
    	var user4 *User
    	DB.Preload("Pets.Toy").Find(&user4, "id = ?", user.ID)
    	if len(user4.Pets) != 0 {
    		t.Fatalf("User.Pet[0] was deleted and should not exist.")
    	}
    
    	var user5 User
    	DB.Unscoped().Preload(clause.Associations+"."+clause.Associations).Find(&user5, "id = ?", user.ID)
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 13.4K bytes
    - Viewed (0)
  7. schema/schema.go

    	var schemaCacheKey interface{}
    	if specialTableName != "" {
    		schemaCacheKey = fmt.Sprintf("%p-%s", modelType, specialTableName)
    	} else {
    		schemaCacheKey = modelType
    	}
    
    	// Load exist schema cache, return if exists
    	if v, ok := cacheStore.Load(schemaCacheKey); ok {
    		s := v.(*Schema)
    		// Wait for the initialization of other goroutines to complete
    		<-s.initialized
    		return s, s.err
    	}
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 06:50:29 GMT 2023
    - 13.7K bytes
    - Viewed (0)
  8. tests/create_test.go

    	CheckUser(t, result2, user2)
    }
    
    func TestFirstOrCreateNotExistsTable(t *testing.T) {
    	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"}
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  9. tests/associations_many2many_test.go

    		t.Fatalf("no error should happen when create languages, but got %v", err)
    	}
    
    	if err := DB.Omit("Languages.*").Create(&user).Error; err != nil {
    		t.Fatalf("no error should happen when create user when languages exists, but got %v", err)
    	}
    
    	// Find
    	var languages []Language
    	if DB.Model(&user).Association("Languages").Find(&languages); len(languages) != 2 {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 13.2K bytes
    - Viewed (0)
  10. migrator/migrator.go

    		tx := m.DB.Session(&gorm.Session{})
    		if err := m.RunWithValue(values[i], func(stmt *gorm.Statement) error {
    			return tx.Exec("DROP TABLE IF EXISTS ?", m.CurrentTable(stmt)).Error
    		}); err != nil {
    			return err
    		}
    	}
    	return nil
    }
    
    // HasTable returns table exists or not for value, value could be a struct or string
    func (m Migrator) HasTable(value interface{}) bool {
    	var count int64
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 28.5K bytes
    - Viewed (0)
Back to top