Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 79 for len (0.12 sec)

  1. tests/helper_test.go

    					"Number")
    			}
    		}
    	})
    
    	t.Run("Pets", func(t *testing.T) {
    		if len(user.Pets) != len(expect.Pets) {
    			t.Fatalf("pets should equal, expect: %v, got %v", len(expect.Pets), len(user.Pets))
    		}
    
    		sort.Slice(user.Pets, func(i, j int) bool {
    			return user.Pets[i].ID > user.Pets[j].ID
    		})
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  2. logger/sql_test.go

    	"encoding/json"
    	"fmt"
    	"regexp"
    	"strings"
    	"testing"
    
    	"github.com/jinzhu/now"
    	"gorm.io/gorm/logger"
    )
    
    type JSON json.RawMessage
    
    func (j JSON) Value() (driver.Value, error) {
    	if len(j) == 0 {
    		return nil, nil
    	}
    	return json.RawMessage(j).MarshalJSON()
    }
    
    type ExampleStruct struct {
    	Name string
    	Val  string
    }
    
    func (s ExampleStruct) Value() (driver.Value, error) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 21 08:00:02 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  3. tests/preload_suits_test.go

    		t.Fatalf("Got error %v", err)
    	}
    
    	var got []Level1
    	if err := DB.Preload("Level2").Preload("Level2.Level3").Find(&got).Error; err != nil {
    		t.Error(err)
    	}
    
    	if len(got) != 2 {
    		t.Errorf("got %v items, expected 2", len(got))
    	}
    
    	if !reflect.DeepEqual(got[0], want) && !reflect.DeepEqual(got[1], want) {
    		t.Fatalf("got %s; want array containing %s", toJSONString(got), toJSONString(want))
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Mar 18 05:38:46 GMT 2022
    - 30.3K bytes
    - Viewed (0)
  4. tests/scan_test.go

    		t.Fatalf("Failed to query with pointer of value, got error %v", err)
    	} else if rus := resInt5.([]User); len(rus) != 3 {
    		t.Fatalf("Scan into struct should work, got %+v, len %v", resInt5, len(rus))
    	}
    }
    
    func TestScanRows(t *testing.T) {
    	user1 := User{Name: "ScanRowsUser1", Age: 1}
    	user2 := User{Name: "ScanRowsUser2", Age: 10}
    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)
  5. schema/index.go

    					length, _  = strconv.Atoi(settings["LENGTH"])
    				)
    
    				if idx == -1 {
    					idx = len(tag)
    				}
    
    				if idx != -1 {
    					name = tag[0:idx]
    				}
    
    				if name == "" {
    					subName := field.Name
    					const key = "COMPOSITE"
    					if composite, found := settings[key]; found {
    						if len(composite) == 0 || composite == key {
    							err = fmt.Errorf(
    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)
  6. tests/associations_has_one_test.go

    	// Count
    	AssertAssociationCount(t, users, "Account", 2, "")
    
    	// Find
    	var accounts []Account
    	if DB.Model(&users).Association("Account").Find(&accounts); len(accounts) != 2 {
    		t.Errorf("accounts count should be %v, but got %v", 3, len(accounts))
    	}
    
    	// Append
    	DB.Model(&users).Association("Account").Append(
    		&Account{Number: "account-slice-append-1"},
    		&Account{Number: "account-slice-append-2"},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
  7. schema/index_test.go

    				return
    			}
    			tests.AssertObjEqual(t, ai, ei, "Name", "Class", "Type", "Where", "Comment", "Option")
    			if len(ei.Fields) != len(ai.Fields) {
    				t.Errorf("expected index %q field length is %d but actual %d", k, len(ei.Fields), len(ai.Fields))
    				return
    			}
    			for i, ef := range ei.Fields {
    				af := ai.Fields[i]
    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. tests/scanner_valuer_test.go

    	ExampleStruct    ExampleStruct
    	ExampleStructPtr *ExampleStruct
    }
    
    type EncryptedData []byte
    
    func (data *EncryptedData) Scan(value interface{}) error {
    	if b, ok := value.([]byte); ok {
    		if len(b) < 3 || b[0] != '*' || b[1] != '*' || b[2] != '*' {
    			return errors.New("Too short")
    		}
    
    		*data = append((*data)[0:], b[3:]...)
    		return nil
    	} else if s, ok := value.(string); ok {
    		*data = []byte(s[3:])
    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)
  9. callbacks/callmethod.go

    	if called := fc(db.Statement.ReflectValue.Interface(), tx); !called {
    		switch db.Statement.ReflectValue.Kind() {
    		case reflect.Slice, reflect.Array:
    			db.Statement.CurDestIndex = 0
    			for i := 0; i < db.Statement.ReflectValue.Len(); i++ {
    				if value := reflect.Indirect(db.Statement.ReflectValue.Index(i)); value.CanAddr() {
    					fc(value.Addr().Interface(), tx)
    				} else {
    					db.AddError(gorm.ErrInvalidValue)
    					return
    				}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 846 bytes
    - Viewed (0)
  10. clause/select.go

    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(',')
    			}
    			builder.WriteQuoted(column)
    		}
    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)
Back to top