Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 121 for struct (0.18 sec)

  1. tests/embedded_struct_test.go

    )
    
    func TestEmbeddedStruct(t *testing.T) {
    	type ReadOnly struct {
    		ReadOnly *bool
    	}
    
    	type BasePost struct {
    		Id    int64
    		Title string
    		URL   string
    		ReadOnly
    	}
    
    	type Author struct {
    		ID    string
    		Name  string
    		Email string
    	}
    
    	type HNPost struct {
    		BasePost
    		Author  `gorm:"EmbeddedPrefix:user_"` // Embedded struct
    		Upvotes int32
    	}
    
    	type EngadgetPost struct {
    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)
  2. tests/scanner_valuer_test.go

    }
    
    type NullString struct {
    	sql.NullString
    }
    
    type Point struct {
    	X, Y int
    }
    
    func (point Point) GormDataType() string {
    	return "geo"
    }
    
    func (point Point) GormValue(ctx context.Context, db *gorm.DB) clause.Expr {
    	return clause.Expr{
    		SQL:  "ST_PointFromText(?)",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jun 07 07:02:07 GMT 2023
    - 10.6K bytes
    - Viewed (0)
  3. tests/scan_test.go

    	. "gorm.io/gorm/utils/tests"
    )
    
    type PersonAddressInfo struct {
    	Person  *Person  `gorm:"embedded"`
    	Address *Address `gorm:"embedded"`
    }
    
    func TestScan(t *testing.T) {
    	user1 := User{Name: "ScanUser1", Age: 1}
    	user2 := User{Name: "ScanUser2", Age: 10}
    	user3 := User{Name: "ScanUser3", Age: 20}
    	DB.Save(&user1).Save(&user2).Save(&user3)
    
    	type result struct {
    		ID   uint
    		Name string
    		Age  int
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat May 28 14:18:07 GMT 2022
    - 8.2K bytes
    - Viewed (0)
  4. prepare_stmt.go

    package gorm
    
    import (
    	"context"
    	"database/sql"
    	"database/sql/driver"
    	"errors"
    	"reflect"
    	"sync"
    )
    
    type Stmt struct {
    	*sql.Stmt
    	Transaction bool
    	prepared    chan struct{}
    	prepareErr  error
    }
    
    type PreparedStmtDB struct {
    	Stmts       map[string]*Stmt
    	PreparedSQL []string
    	Mux         *sync.RWMutex
    	ConnPool
    }
    
    func NewPreparedStmtDB(connPool ConnPool) *PreparedStmtDB {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 28 08:47:39 GMT 2024
    - 6.4K bytes
    - Viewed (0)
  5. schema/utils.go

    		appendToResults := func(value reflect.Value) {
    			if _, isZero := rel.Field.ValueOf(ctx, value); !isZero {
    				result := reflect.Indirect(rel.Field.ReflectValueOf(ctx, value))
    				switch result.Kind() {
    				case reflect.Struct:
    					reflectResults = reflect.Append(reflectResults, result.Addr())
    				case reflect.Slice, reflect.Array:
    					for i := 0; i < result.Len(); i++ {
    						if elem := result.Index(i); elem.Kind() == reflect.Ptr {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Aug 19 13:35:14 GMT 2023
    - 5.5K bytes
    - Viewed (0)
  6. clause/select.go

    package clause
    
    // Select select attrs when querying, updating, creating
    type Select struct {
    	Distinct   bool
    	Columns    []Column
    	Expression Expression
    }
    
    func (s Select) Name() string {
    	return "SELECT"
    }
    
    func (s Select) Build(builder Builder) {
    	if len(s.Columns) > 0 {
    		if s.Distinct {
    			builder.WriteString("DISTINCT ")
    		}
    
    		for idx, column := range s.Columns {
    			if idx > 0 {
    				builder.WriteByte(',')
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jul 14 07:51:24 GMT 2021
    - 1.1K bytes
    - Viewed (0)
  7. schema/index_test.go

    	CompIdxLevel2C
    }
    
    type CompIdxLevel1C struct {
    	CompIdxLevel1B
    	Data1C string `gorm:"index:,composite:comp_id1"`
    }
    
    type CompIdxLevel1B struct {
    	Data1B string `gorm:"index:,composite:comp_id1"`
    }
    
    type CompIdxLevel2C struct {
    	CompIdxLevel2B
    	Data2C string `gorm:"index:,unique,composite:comp_id2,priority:1"`
    }
    
    type CompIdxLevel2B struct {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 8K bytes
    - Viewed (0)
  8. schema/index.go

    import (
    	"fmt"
    	"sort"
    	"strconv"
    	"strings"
    )
    
    type Index struct {
    	Name    string
    	Class   string // UNIQUE | FULLTEXT | SPATIAL
    	Type    string // btree, hash, gist, spgist, gin, and brin
    	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
    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)
  9. tests/update_test.go

    		t.Errorf("errors happened when update: %v", err)
    	} else if user.Age != 2 {
    		t.Errorf("Age should equals to 2, but got %v", user.Age)
    	}
    	checkUpdatedAtChanged("Updates with struct", user.UpdatedAt)
    	checkOtherData("Updates with struct")
    
    	var result3 User
    	if err := DB.Where("id = ?", user.ID).First(&result3).Error; err != nil {
    		t.Errorf("errors happened when query: %v", err)
    	} else {
    		CheckUser(t, result3, *user)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  10. schema/relationship_test.go

    	})
    }
    
    func TestEmbeddedBelongsTo(t *testing.T) {
    	type Country struct {
    		ID   int `gorm:"primaryKey"`
    		Name string
    	}
    	type Address struct {
    		CountryID int
    		Country   Country
    	}
    	type NestedAddress struct {
    		Address
    	}
    	type CountryMixin struct {
    		CountryID int
    		Country   Country
    	}
    	type Org struct {
    		ID              int
    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)
Back to top