Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 33 for PrimaryKey (0.22 sec)

  1. 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)
  2. callbacks/query.go

    							for idx, ref := range relation.References {
    								if ref.OwnPrimaryKey {
    									exprs[idx] = clause.Eq{
    										Column: clause.Column{Table: parentTableName, Name: ref.PrimaryKey.DBName},
    										Value:  clause.Column{Table: tableAliasName, Name: ref.ForeignKey.DBName},
    									}
    								} else {
    									if ref.PrimaryValue == "" {
    										exprs[idx] = clause.Eq{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Jan 29 03:34:57 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  3. tests/migrate_test.go

    	if DB.Dialector.Name() != "postgres" {
    		return
    	}
    
    	type Event struct {
    		ID  uint `gorm:"primarykey"`
    		UID uint32
    	}
    
    	type Event1 struct {
    		ID  uint   `gorm:"primarykey"`
    		UID uint32 `gorm:"not null;autoIncrement"`
    	}
    
    	type Event2 struct {
    		ID  uint   `gorm:"primarykey"`
    		UID uint16 `gorm:"not null;autoIncrement"`
    	}
    
    	var err error
    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. callbacks/delete.go

    					tx             = db.Session(&gorm.Session{NewDB: true}).Model(modelValue).Table(table)
    				)
    
    				for _, ref := range rel.References {
    					if ref.OwnPrimaryKey {
    						foreignFields = append(foreignFields, ref.PrimaryKey)
    						relForeignKeys = append(relForeignKeys, ref.ForeignKey.DBName)
    					} else if ref.PrimaryValue != "" {
    						queryConds = append(queryConds, clause.Eq{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Feb 25 02:48:23 GMT 2022
    - 5.6K bytes
    - Viewed (0)
  5. schema/field_test.go

    	if err != nil {
    		t.Fatalf("Failed to parse user with permission, got error %v", err)
    	}
    
    	fields := []*schema.Field{
    		{Name: "ID", DBName: "id", BindNames: []string{"ID"}, DataType: schema.Uint, PrimaryKey: true, Size: 64, Creatable: true, Updatable: true, Readable: true, HasDefaultValue: true, AutoIncrement: true},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 19 09:02:53 GMT 2022
    - 12.7K bytes
    - Viewed (0)
  6. tests/multi_primary_keys_test.go

    		t.Fatalf("EN Blog's tags should be cleared")
    	}
    }
    
    func TestCompositePrimaryKeysAssociations(t *testing.T) {
    	type Label struct {
    		BookID *uint  `gorm:"primarykey"`
    		Name   string `gorm:"primarykey"`
    		Value  string
    	}
    
    	type Book struct {
    		ID     int
    		Name   string
    		Labels []Label
    	}
    
    	DB.Migrator().DropTable(&Label{}, &Book{})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 12.8K bytes
    - Viewed (0)
  7. clause/expression_test.go

    	}, {
    		SQL:    "?",
    		Vars:   []interface{}{clause.Column{Table: "table", Name: "col", Raw: true}},
    		Result: "table.col",
    	}, {
    		SQL:    "?",
    		Vars:   []interface{}{clause.Column{Table: "table", Name: clause.PrimaryKey, Raw: true}},
    		Result: "table.id",
    	}, {
    		SQL:    "?",
    		Vars:   []interface{}{clause.Column{Table: "table", Name: "col", Alias: "alias"}},
    		Result: "`table`.`col` AS `alias`",
    	}, {
    		SQL:    "?",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Aug 10 05:34:33 GMT 2023
    - 8.4K bytes
    - Viewed (0)
  8. 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)
  9. callbacks/update.go

    		case reflect.Struct:
    			set = make([]clause.Assignment, 0, len(stmt.Schema.FieldsByDBName))
    			for _, dbName := range stmt.Schema.DBNames {
    				if field := updatingSchema.LookUpField(dbName); field != nil {
    					if !field.PrimaryKey || !updatingValue.CanAddr() || stmt.Dest != stmt.Model {
    						if v, ok := selectColumns[field.DBName]; (ok && v) || (!ok && (!restricted || (!stmt.SkipHooks && field.AutoUpdateTime > 0))) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 05:44:55 GMT 2024
    - 9.4K bytes
    - Viewed (1)
  10. tests/upsert_test.go

    		t.Fatalf("failed to upsert, got name %v", result.Name)
    	}
    
    	if name := DB.Dialector.Name(); name != "sqlserver" {
    		type RestrictedLanguage struct {
    			Code string `gorm:"primarykey"`
    			Name string
    			Lang string `gorm:"<-:create"`
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
Back to top