Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 33 for parse (0.22 sec)

  1. schema/callbacks_test.go

    	return nil
    }
    
    func (UserWithCallback) AfterCreate(*gorm.DB) error {
    	return nil
    }
    
    func TestCallback(t *testing.T) {
    	user, err := schema.Parse(&UserWithCallback{}, &sync.Map{}, schema.NamingStrategy{})
    	if err != nil {
    		t.Fatalf("failed to parse user with callback, got error %v", err)
    	}
    
    	for _, str := range []string{"BeforeSave", "AfterCreate"} {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 939 bytes
    - Viewed (0)
  2. schema/index_test.go

    }
    
    type CompIdxLevel2B struct {
    	Data2B string `gorm:"index:,unique,composite:comp_id2,priority:3"`
    }
    
    func TestParseIndex(t *testing.T) {
    	user, err := schema.Parse(&UserIndex{}, &sync.Map{}, schema.NamingStrategy{})
    	if err != nil {
    		t.Fatalf("failed to parse user index, got error %v", err)
    	}
    
    	results := map[string]schema.Index{
    		"idx_user_indices_name": {
    			Name:   "idx_user_indices_name",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 8K bytes
    - Viewed (0)
  3. schema/relationship_test.go

    import (
    	"sync"
    	"testing"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/schema"
    )
    
    func checkStructRelation(t *testing.T, data interface{}, relations ...Relation) {
    	if s, err := schema.Parse(data, &sync.Map{}, schema.NamingStrategy{}); err != nil {
    		t.Errorf("Failed to parse schema, got error %v", err)
    	} else {
    		for _, rel := range relations {
    			checkSchemaRelation(t, s, rel)
    		}
    	}
    }
    
    func TestBelongsToOverrideForeignKey(t *testing.T) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  4. schema/index.go

    	Where   string
    	Comment string
    	Option  string        // WITH PARSER parser_name
    	Fields  []IndexOption // Note: IndexOption's Field maybe the same
    }
    
    type IndexOption struct {
    	*Field
    	Expression string
    	Sort       string // DESC, ASC
    	Collate    string
    	Length     int
    	priority   int
    }
    
    // ParseIndexes parse schema indexes
    func (schema *Schema) ParseIndexes() map[string]Index {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  5. schema/constraint.go

    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
    func (schema *Schema) ParseCheckConstraints() map[string]CheckConstraint {
    	checks := map[string]CheckConstraint{}
    	for _, field := range schema.FieldsByDBName {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 07:33:54 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  6. tests/embedded_struct_test.go

    		if !DB.Migrator().HasColumn(&EngadgetPost{}, name) {
    			t.Errorf("should has prefixed column %v", name)
    		}
    	}
    
    	stmt := gorm.Statement{DB: DB}
    	if err := stmt.Parse(&EngadgetPost{}); err != nil {
    		t.Fatalf("failed to parse embedded struct")
    	} else if len(stmt.Schema.PrimaryFields) != 1 {
    		t.Errorf("should have only one primary field with embedded struct, but got %v", len(stmt.Schema.PrimaryFields))
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Oct 26 03:58:13 GMT 2023
    - 7.3K bytes
    - Viewed (0)
  7. callbacks/create_test.go

    	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 {
    		t.Errorf("parse schema error: %v, is not expected", err)
    		return
    	}
    	dest := []*user{
    		{
    			ID:    1,
    			Name:  "alice",
    			Email: "email",
    			Age:   18,
    		},
    		{
    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)
  8. callbacks.go

    	}
    
    	// assign model values
    	if stmt.Model == nil {
    		stmt.Model = stmt.Dest
    	} else if stmt.Dest == nil {
    		stmt.Dest = stmt.Model
    	}
    
    	// parse model values
    	if stmt.Model != nil {
    		if err := stmt.Parse(stmt.Model); err != nil && (!errors.Is(err, schema.ErrUnsupportedDataType) || (stmt.Table == "" && stmt.TableExpr == nil && stmt.SQL.Len() == 0)) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 26 03:33:36 GMT 2024
    - 8.6K bytes
    - Viewed (1)
  9. clause/benchmarks_test.go

    package clause_test
    
    import (
    	"sync"
    	"testing"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils/tests"
    )
    
    func BenchmarkSelect(b *testing.B) {
    	user, _ := schema.Parse(&tests.User{}, &sync.Map{}, db.NamingStrategy)
    
    	for i := 0; i < b.N; i++ {
    		stmt := gorm.Statement{DB: db, Table: user.Table, Schema: user, Clauses: map[string]clause.Clause{}}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Oct 07 12:14:14 GMT 2022
    - 1.9K bytes
    - Viewed (0)
  10. tests/table_test.go

    	}
    
    	t.Run("default", func(t *testing.T) {
    		db, _ := gorm.Open(postgres.Open(postgresDSN), &gorm.Config{})
    		user, err := schema.Parse(&LongString{}, &sync.Map{}, db.Config.NamingStrategy)
    		if err != nil {
    			t.Fatalf("failed to parse user unique, got error %v", err)
    		}
    
    		constraints := user.ParseUniqueConstraints()
    		if len(constraints) != 1 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
Back to top