Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 19 for constraint (0.22 sec)

  1. schema/constraint.go

    	Name       string
    	Constraint string // length(phone) >= 10
    	*Field
    }
    
    func (chk *CheckConstraint) GetName() string { return chk.Name }
    
    func (chk *CheckConstraint) Build() (sql string, vars []interface{}) {
    	return "CONSTRAINT ? CHECK (?)", []interface{}{clause.Column{Name: chk.Name}, clause.Expr{SQL: chk.Constraint}}
    }
    
    // ParseCheckConstraints parse schema check constraints
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 07:33:54 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  2. schema/constraint_test.go

    	results := map[string]schema.CheckConstraint{
    		"name_checker": {
    			Name:       "name_checker",
    			Constraint: "name <> 'jinzhu'",
    		},
    		"chk_user_checks_name2": {
    			Name:       "chk_user_checks_name2",
    			Constraint: "name <> 'jinzhu'",
    		},
    		"chk_user_checks_name3": {
    			Name:       "chk_user_checks_name3",
    			Constraint: "name <> 'jinzhu'",
    		},
    	}
    
    	checks := user.ParseCheckConstraints()
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 2.2K bytes
    - Viewed (0)
  3. migrator/migrator.go

    		currentDatabase := m.DB.Migrator().CurrentDatabase()
    		constraint, table := m.GuessConstraintInterfaceAndTable(stmt, name)
    		if constraint != nil {
    			name = constraint.GetName()
    		}
    
    		return m.DB.Raw(
    			"SELECT count(*) FROM INFORMATION_SCHEMA.table_constraints WHERE constraint_schema = ? AND table_name = ? AND constraint_name = ?",
    			currentDatabase, table, name,
    		).Row().Scan(&count)
    	})
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  4. utils/tests/models.go

    type Language struct {
    	Code string `gorm:"primarykey"`
    	Name string
    }
    
    type Coupon struct {
    	ID               int              `gorm:"primarykey; size:255"`
    	AppliesToProduct []*CouponProduct `gorm:"foreignKey:CouponId;constraint:OnDelete:CASCADE"`
    	AmountOff        uint32           `gorm:"column:amount_off"`
    	PercentOff       float32          `gorm:"column:percent_off"`
    }
    
    type CouponProduct struct {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  5. 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)
  6. tests/postgres_test.go

    		gorm.Model
    		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)
    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/multi_primary_keys_test.go

    		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")
    	if err := DB.AutoMigrate(&Blog{}, &Tag{}); err != nil {
    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)
  8. tests/error_translator_test.go

    	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"`
    	}
    
    	db, err := OpenTestConnection(&gorm.Config{TranslateError: true})
    	if err != nil {
    		t.Fatalf("failed to connect database, got error %v", err)
    	}
    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)
  9. schema/relationship.go

    	sql = "CONSTRAINT ? FOREIGN KEY ? REFERENCES ??"
    	if constraint.OnDelete != "" {
    		sql += " ON DELETE " + constraint.OnDelete
    	}
    
    	if constraint.OnUpdate != "" {
    		sql += " ON UPDATE " + constraint.OnUpdate
    	}
    
    	foreignKeys := make([]interface{}, 0, len(constraint.ForeignKeys))
    	for _, field := range constraint.ForeignKeys {
    		foreignKeys = append(foreignKeys, clause.Column{Name: field.DBName})
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  10. clause/on_conflict.go

    	Where        Where
    	TargetWhere  Where
    	OnConstraint string
    	DoNothing    bool
    	DoUpdates    Set
    	UpdateAll    bool
    }
    
    func (OnConflict) Name() string {
    	return "ON CONFLICT"
    }
    
    // Build build onConflict clause
    func (onConflict OnConflict) Build(builder Builder) {
    	if onConflict.OnConstraint != "" {
    		builder.WriteString("ON CONSTRAINT ")
    		builder.WriteString(onConflict.OnConstraint)
    		builder.WriteByte(' ')
    	} else {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Oct 07 05:46:20 GMT 2022
    - 1.3K bytes
    - Viewed (0)
Back to top