Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for unique_name (0.17 sec)

  1. tests/table_test.go

    		for key := range constraints {
    			if len(key) != 63 {
    				t.Errorf("failed to find unique constraint, got %v", constraints)
    			}
    		}
    	})
    
    	t.Run("namer", func(t *testing.T) {
    		uname := "custom_unique_name"
    		db, _ := gorm.Open(postgres.Open(postgresDSN), &gorm.Config{
    			NamingStrategy: mockUniqueNamingStrategy{
    				UName: uname,
    			},
    		})
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  2. schema/constraint.go

    func (schema *Schema) ParseUniqueConstraints() map[string]UniqueConstraint {
    	uniques := make(map[string]UniqueConstraint)
    	for _, field := range schema.Fields {
    		if field.Unique {
    			name := schema.namer.UniqueName(schema.Table, field.DBName)
    			uniques[name] = UniqueConstraint{Name: name, Field: field}
    		}
    	}
    	return uniques
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 07:33:54 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  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 21 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  4. migrator/migrator.go

    	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
    		constraint := m.DB.NamingStrategy.UniqueName(stmt.Table, field.DBName)
    		if unique && !field.Unique {
    			return m.DB.Migrator().DropConstraint(value, constraint)
    		}
    		if !unique && field.Unique {
    			return m.DB.Migrator().CreateConstraint(value, constraint)
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 28.5K bytes
    - Viewed (0)
  5. tests/migrate_test.go

    	// UniqueAffectedByUniqueIndex is true
    	if DB.Dialector.Name() == "mysql" {
    		uniqueConstraintIndex := &migrator.Index{TableName: table, NameValue: DB.Config.NamingStrategy.UniqueName(table, "name"), ColumnList: []string{"name"}, PrimaryKeyValue: sql.NullBool{Bool: false, Valid: true}, UniqueValue: sql.NullBool{Bool: true, Valid: true}}
    		checkNotUnique = func(t *testing.T) {
    			checkColumnType(t, "name", false)
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top