- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 21 for uniqBy (0.22 sec)
-
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) -
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) -
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) -
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) -
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) -
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) -
schema/naming.go
} // IndexName generate index name func (ns NamingStrategy) IndexName(table, column string) string { return ns.formatName("idx", table, ns.toDBName(column)) } // UniqueName generate unique constraint name func (ns NamingStrategy) UniqueName(table, column string) string { return ns.formatName("uni", table, ns.toDBName(column)) } func (ns NamingStrategy) formatName(prefix, table, name string) string {
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Mon Oct 30 09:15:49 GMT 2023 - 5.2K bytes - Viewed (0) -
schema/schema_helper_test.go
} else { tests.AssertObjEqual(t, parsedField, f, "Name", "DBName", "BindNames", "DataType", "PrimaryKey", "AutoIncrement", "Creatable", "Updatable", "Readable", "HasDefaultValue", "DefaultValue", "NotNull", "Unique", "Comment", "Size", "Precision", "TagSettings") if f.DBName != "" { if field, ok := s.FieldsByDBName[f.DBName]; !ok || parsedField != field { t.Errorf("schema %v failed to look up field with dbname %v", s, f.DBName)
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Fri Dec 15 08:31:23 GMT 2023 - 7.5K bytes - Viewed (0) -
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) -
tests/multi_primary_keys_test.go
} if name := DB.Dialector.Name(); name == "postgres" { stmt := gorm.Statement{DB: DB} stmt.Parse(&Blog{}) stmt.Schema.LookUpField("ID").Unique = true stmt.Parse(&Tag{}) stmt.Schema.LookUpField("ID").Unique = true // postgers only allow unique constraint matching given keys } DB.Migrator().DropTable(&Blog{}, &Tag{}, "blog_tags", "locale_blog_tags", "shared_blog_tags")
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 12.8K bytes - Viewed (0)