Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 42 for key (0.16 sec)

  1. tests/create_test.go

    	}
    
    	jt := JoinTable{UserID: 1, FriendID: 2}
    	err := DB.Create(&jt).Error
    	if err != nil {
    		t.Errorf("No error should happen when create a record without a GORM primary key. But in the database this primary key exists and is the union of 2 or more fields\n But got: %s", err)
    	}
    }
    
    func TestSelectWithCreate(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. schema/relationship_test.go

    		},
    	})
    }
    
    func TestMany2ManyWithMultiPrimaryKeys(t *testing.T) {
    	type Tag struct {
    		ID     uint   `gorm:"primary_key"`
    		Locale string `gorm:"primary_key"`
    		Value  string
    	}
    
    	type Blog struct {
    		ID         uint   `gorm:"primary_key"`
    		Locale     string `gorm:"primary_key"`
    		Subject    string
    		Body       string
    		Tags       []Tag `gorm:"many2many:blog_tags;"`
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  3. schema/index.go

    					idx = len(tag)
    				}
    
    				if idx != -1 {
    					name = tag[0:idx]
    				}
    
    				if name == "" {
    					subName := field.Name
    					const key = "COMPOSITE"
    					if composite, found := settings[key]; found {
    						if len(composite) == 0 || composite == key {
    							err = fmt.Errorf(
    								"The composite tag of %s.%s cannot be empty",
    								field.Schema.Name,
    								field.Name)
    							return
    						}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  4. schema/utils.go

    			queryValues[idx] = r[0]
    		}
    
    		return clause.Column{Table: table, Name: foreignKeys[0]}, queryValues
    	}
    
    	columns := make([]clause.Column, len(foreignKeys))
    	for idx, key := range foreignKeys {
    		columns[idx] = clause.Column{Table: table, Name: key}
    	}
    
    	for idx, r := range foreignValues {
    		queryValues[idx] = r
    	}
    
    	return columns, queryValues
    }
    
    type embeddedNamer struct {
    	Table string
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Aug 19 13:35:14 GMT 2023
    - 5.5K bytes
    - Viewed (0)
  5. tests/helper_test.go

    		AssertObjEqual(t, user.Account, expect.Account, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Number")
    
    		if user.Account.Number != "" {
    			if !user.Account.UserID.Valid {
    				t.Errorf("Account's foreign key should be saved")
    			} else {
    				var account Account
    				db(unscoped).First(&account, "user_id = ?", user.ID)
    				AssertObjEqual(t, account, user.Account, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  6. tests/update_test.go

    	Name  string
    	Token Token `gorm:"foreignKey:UserID"`
    }
    
    func (t *TokenOwner) BeforeSave(tx *gorm.DB) error {
    	t.Name += "_name"
    	return nil
    }
    
    type Token struct {
    	UserID  int    `gorm:"primary_key"`
    	Content string `gorm:"type:varchar(100)"`
    }
    
    func (t *Token) BeforeSave(tx *gorm.DB) error {
    	t.Content += "_encrypted"
    	return nil
    }
    
    func TestSaveWithHooks(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)
  7. clause/set.go

    }
    
    func Assignments(values map[string]interface{}) Set {
    	keys := make([]string, 0, len(values))
    	for key := range values {
    		keys = append(keys, key)
    	}
    	sort.Strings(keys)
    
    	assignments := make([]Assignment, len(keys))
    	for idx, key := range keys {
    		assignments[idx] = Assignment{Column: Column{Name: key}, Value: values[key]}
    	}
    	return assignments
    }
    
    func AssignmentColumns(values []string) Set {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Nov 29 03:02:44 GMT 2021
    - 1.4K bytes
    - Viewed (0)
  8. migrator/index.go

    func (idx Index) Name() string {
    	return idx.NameValue
    }
    
    // Columns return the columns of the index
    func (idx Index) Columns() []string {
    	return idx.ColumnList
    }
    
    // PrimaryKey returns the index is primary key or not.
    func (idx Index) PrimaryKey() (isPrimaryKey bool, ok bool) {
    	return idx.PrimaryKeyValue.Bool, idx.PrimaryKeyValue.Valid
    }
    
    // Unique returns whether the index is unique or not.
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Apr 11 02:32:46 GMT 2023
    - 1023 bytes
    - Viewed (0)
  9. errors.go

    	// ErrDuplicatedKey occurs when there is a unique key constraint violation
    	ErrDuplicatedKey = errors.New("duplicated key not allowed")
    	// ErrForeignKeyViolated occurs when there is a foreign key constraint violation
    	ErrForeignKeyViolated = errors.New("violates foreign key constraint")
    	// ErrCheckConstraintViolated occurs when there is a check constraint violation
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 02:53:17 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  10. migrator/migrator.go

    					values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field))
    					createTableSQL += ","
    				}
    			}
    
    			if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 {
    				createTableSQL += "PRIMARY KEY ?,"
    				primaryKeys := make([]interface{}, 0, len(stmt.Schema.PrimaryFields))
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
Back to top