Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 21 for unique (0.18 sec)

  1. schema/index_test.go

    		FieldF2 string `gorm:"uniqueIndex:uniq_field_f1_f2;"`
    
    		FieldG string `gorm:"unique;uniqueIndex"` // unique and uniqueIndex
    
    		FieldH1 string `gorm:"unique;uniqueIndex:uniq_field_h1_h2"` // unique and mul uniqueIndex
    		FieldH2 string `gorm:"uniqueIndex:uniq_field_h1_h2"`        // unique and mul uniqueIndex
    	}
    	indexSchema, err := schema.Parse(&IndexTest{}, &sync.Map{}, schema.NamingStrategy{})
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 8K bytes
    - Viewed (0)
  2. schema/index.go

    							return
    						}
    						subName = composite
    					}
    					name = field.Schema.namer.IndexName(
    						field.Schema.Table, subName)
    				}
    
    				if (k == "UNIQUEINDEX") || settings["UNIQUE"] != "" {
    					settings["CLASS"] = "UNIQUE"
    				}
    
    				priority, err := strconv.Atoi(settings["PRIORITY"])
    				if err != nil {
    					priority = 10
    				}
    
    				indexes = append(indexes, Index{
    					Name:    name,
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  3. migrator/index.go

    // 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.
    func (idx Index) Unique() (unique bool, ok bool) {
    	return idx.UniqueValue.Bool, idx.UniqueValue.Valid
    }
    
    // Option return the optional attribute of the index
    func (idx Index) Option() string {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Apr 11 02:32:46 GMT 2023
    - 1023 bytes
    - Viewed (0)
  4. migrator/migrator.go

    	unique, ok := columnType.Unique()
    	if !ok || field.PrimaryKey {
    		return nil // skip primary key
    	}
    	// By default, ColumnType's Unique is not affected by UniqueIndex, so we don't care about UniqueIndex.
    	return m.RunWithValue(value, func(stmt *gorm.Statement) error {
    		// We're currently only receiving boolean values on `Unique` tag,
    		// so the UniqueConstraint name is fixed
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  5. tests/hooks_test.go

    	DB.Migrator().DropTable(&Product{})
    	DB.AutoMigrate(&Product{})
    
    	p := Product{Code: "unique_code", Price: 100}
    	DB.Save(&p)
    
    	if !reflect.DeepEqual(p.GetCallTimes(), []int64{1, 1, 0, 1, 1, 0, 0, 0, 0}) {
    		t.Fatalf("Callbacks should be invoked successfully, %v", p.GetCallTimes())
    	}
    
    	DB.Where("Code = ?", "unique_code").First(&p)
    	if !reflect.DeepEqual(p.GetCallTimes(), []int64{1, 1, 0, 1, 0, 0, 0, 0, 1}) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  6. tests/postgres_test.go

    		SomeID  string
    		OtherID string
    		Data    string
    	}
    
    	DB.Migrator().DropTable(&Thing{})
    	DB.Migrator().CreateTable(&Thing{})
    	if err := DB.Exec("ALTER TABLE things ADD CONSTRAINT some_id_other_id_unique UNIQUE (some_id, other_id)").Error; err != nil {
    		t.Error(err)
    	}
    
    	thing := Thing{
    		SomeID:  "1234",
    		OtherID: "1234",
    		Data:    "something",
    	}
    
    	DB.Create(&thing)
    
    	thing2 := Thing{
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Oct 08 09:16:32 GMT 2022
    - 6.4K bytes
    - Viewed (3)
  7. tests/error_translator_test.go

    func TestSupportedDialectorWithErrForeignKeyViolated(t *testing.T) {
    	tidbSkip(t, "not support the foreign key feature")
    
    	type City struct {
    		gorm.Model
    		Name string `gorm:"unique"`
    	}
    
    	type Museum struct {
    		gorm.Model
    		Name   string `gorm:"unique"`
    		CityID uint
    		City   City `gorm:"Constraint:OnUpdate:CASCADE,OnDelete:CASCADE;FOREIGNKEY:CityID;References:ID"`
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Jul 12 13:21:22 GMT 2023
    - 3.1K bytes
    - Viewed (0)
  8. tests/migrate_test.go

    		if field == nil {
    			t.Fatalf("%v: failed to find column %q", utils.FileWithLineNum(), fieldName)
    		}
    		if field.Unique != unique {
    			t.Fatalf("%v: %q column %q unique should be %v but got %v", utils.FileWithLineNum(), stmt.Schema.Table, fieldName, unique, field.Unique)
    		}
    		if field.UniqueIndex != uniqueIndex {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  9. migrator.go

    	Nullable() (nullable bool, ok bool)
    	Unique() (unique bool, ok bool)
    	ScanType() reflect.Type
    	Comment() (value string, ok bool)
    	DefaultValue() (value string, ok bool)
    }
    
    type Index interface {
    	Table() string
    	Name() string
    	Columns() []string
    	PrimaryKey() (isPrimaryKey bool, ok bool)
    	Unique() (unique bool, ok bool)
    	Option() string
    }
    
    // TableType table type interface
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 3.1K bytes
    - Viewed (0)
  10. tests/table_test.go

    		if err != nil {
    			t.Fatalf("failed to parse user unique, got error %v", err)
    		}
    
    		constraints := user.ParseUniqueConstraints()
    		if len(constraints) != 1 {
    			t.Fatalf("failed to find unique constraint, got %v", constraints)
    		}
    
    		for key := range constraints {
    			if len(key) != 63 {
    				t.Errorf("failed to find unique constraint, got %v", constraints)
    			}
    		}
    	})
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
Back to top