Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 12 for primary_key (0.17 sec)

  1. 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)
  2. schema/field.go

    				}
    
    				if prefix, ok := field.TagSettings["EMBEDDEDPREFIX"]; ok && ef.DBName != "" {
    					ef.DBName = prefix + ef.DBName
    				}
    
    				if ef.PrimaryKey {
    					if !utils.CheckTruth(ef.TagSettings["PRIMARYKEY"], ef.TagSettings["PRIMARY_KEY"]) {
    						ef.PrimaryKey = false
    
    						if val, ok := ef.TagSettings["AUTOINCREMENT"]; !ok || !utils.CheckTruth(val) {
    							ef.AutoIncrement = false
    						}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 32K bytes
    - Viewed (1)
  3. tests/migrate_test.go

    		return
    	}
    
    	type UniqueTest struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique"`
    	}
    
    	type UniqueTest2 struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique;default:NULL"`
    	}
    
    	type UniqueTest3 struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique;default:''"`
    	}
    
    	type UniqueTest4 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)
  4. tests/query_test.go

    	}
    
    	AssertEqual(t, p, p2)
    }
    
    func TestStringPrimaryKeyForNumericValueStartingWithZero(t *testing.T) {
    	type AddressByZipCode struct {
    		ZipCode string `gorm:"primary_key"`
    		Address string
    	}
    
    	DB.Migrator().DropTable(&AddressByZipCode{})
    	if err := DB.AutoMigrate(&AddressByZipCode{}); err != nil {
    		t.Fatalf("failed to migrate, got error %v", err)
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
  5. schema/relationship.go

    	} else {
    		primarySchemaName := primarySchema.Name
    		if primarySchemaName == "" {
    			primarySchemaName = relation.FieldSchema.Name
    		}
    
    		if len(relation.primaryKeys) > 0 {
    			for _, primaryKey := range relation.primaryKeys {
    				if f := primarySchema.LookUpField(primaryKey); f != nil {
    					primaryFields = append(primaryFields, f)
    				}
    			}
    		} else {
    			primaryFields = primarySchema.PrimaryFields
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  6. migrator/migrator.go

    				createTableSQL += "PRIMARY KEY ?,"
    				primaryKeys := make([]interface{}, 0, len(stmt.Schema.PrimaryFields))
    				for _, field := range stmt.Schema.PrimaryFields {
    					primaryKeys = append(primaryKeys, clause.Column{Name: field.DBName})
    				}
    
    				values = append(values, primaryKeys)
    			}
    
    			for _, idx := range stmt.Schema.ParseIndexes() {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  7. callbacks/preload.go

    				foreignFields = append(foreignFields, ref.PrimaryKey)
    			} else if ref.PrimaryValue != "" {
    				tx = tx.Where(clause.Eq{Column: ref.ForeignKey.DBName, Value: ref.PrimaryValue})
    			} else {
    				joinRelForeignFields = append(joinRelForeignFields, ref.ForeignKey)
    				relForeignKeys = append(relForeignKeys, ref.PrimaryKey.DBName)
    				relForeignFields = append(relForeignFields, ref.PrimaryKey)
    			}
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  8. tests/create_test.go

    	company := Company{ID: 100, Name: "company100_with_primarykey"}
    	DB.FirstOrCreate(&company)
    
    	if company.ID != 100 {
    		t.Errorf("invalid primary key after creating, got %v", company.ID)
    	}
    
    	companies := []Company{
    		{ID: 101, Name: "company101_with_primarykey"},
    		{ID: 102, Name: "company102_with_primarykey"},
    	}
    	DB.Create(&companies)
    
    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)
  9. callbacks/create_test.go

    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    )
    
    var schemaCache = &sync.Map{}
    
    func TestConvertToCreateValues_DestType_Slice(t *testing.T) {
    	type user struct {
    		ID    int `gorm:"primaryKey"`
    		Name  string
    		Email string `gorm:"default:(-)"`
    		Age   int    `gorm:"default:(-)"`
    	}
    
    	s, err := schema.Parse(&user{}, schemaCache, schema.NamingStrategy{})
    	if err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 05:48:42 GMT 2024
    - 1.4K bytes
    - Viewed (0)
  10. callbacks/create.go

    				for _, column := range values.Columns {
    					if field := stmt.Schema.LookUpField(column.Name); field != nil {
    						if v, ok := selectColumns[field.DBName]; (ok && v) || (!ok && !restricted) {
    							if !field.PrimaryKey && (!field.HasDefaultValue || field.DefaultValueInterface != nil ||
    								strings.EqualFold(field.DefaultValue, "NULL")) && field.AutoCreateTime == 0 {
    								if field.AutoUpdateTime > 0 {
    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)
Back to top