Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 26 for scwang (0.18 sec)

  1. tests/scan_test.go

    	if res.ID != user3.ID || res.Name != user3.Name || res.Age != int(user3.Age) {
    		t.Fatalf("Scan into struct should work, got %#v, should %#v", res, user3)
    	}
    
    	doubleAgeRes := &result{}
    	if err := DB.Table("users").Select("age + age as age").Where("id = ?", user3.ID).Scan(&doubleAgeRes).Error; err != nil {
    		t.Errorf("Scan to pointer of pointer")
    	}
    
    	if doubleAgeRes.Age != int(res.Age)*2 {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat May 28 14:18:07 GMT 2022
    - 8.2K bytes
    - Viewed (0)
  2. tests/scanner_valuer_test.go

    	// prepend asterisks
    	return append([]byte("***"), data...), nil
    }
    
    type Num int64
    
    func (i *Num) Scan(src interface{}) error {
    	switch s := src.(type) {
    	case []byte:
    		n, _ := strconv.Atoi(string(s))
    		*i = Num(n)
    	case int64:
    		*i = Num(s)
    	default:
    		return errors.New("Cannot scan NamedInt from " + reflect.ValueOf(src).String())
    	}
    	return nil
    }
    
    type StringsSlice []string
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Jun 07 07:02:07 GMT 2023
    - 10.6K bytes
    - Viewed (0)
  3. tests/transaction_test.go

    	DB.Create(&user)
    
    	var err error
    	err = DB.Transaction(func(tx *gorm.DB) error {
    		return tx.Model(&User{}).Limit(1).Transaction(func(tx2 *gorm.DB) error {
    			return tx2.Scan(&User{}).Error
    		})
    	})
    
    	if err != nil {
    		t.Error(err)
    	}
    
    	// method with hooks
    	err = DB.Transaction(func(tx1 *gorm.DB) error {
    		// callMethod do
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  4. tests/connection_test.go

    	if len(setSQL) == 0 || len(getSQL) == 0 {
    		return
    	}
    
    	err := DB.Connection(func(tx *gorm.DB) error {
    		if err := tx.Exec(setSQL, expectedName).Error; err != nil {
    			return err
    		}
    
    		if err := tx.Raw(getSQL).Scan(&actualName).Error; err != nil {
    			return err
    		}
    		return nil
    	})
    	if err != nil {
    		t.Errorf(fmt.Sprintf("WithSingleConnection should work, but got err %v", err))
    	}
    
    	if actualName != expectedName {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Jan 28 14:16:42 GMT 2022
    - 963 bytes
    - Viewed (0)
  5. tests/serializer_test.go

    	}
    	return s
    }
    
    type Roles []string
    
    type Job struct {
    	Title    string
    	Number   int
    	Location string
    	IsIntern bool
    }
    
    type EncryptedString string
    
    func (es *EncryptedString) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error) {
    	switch value := dbValue.(type) {
    	case []byte:
    		*es = EncryptedString(bytes.TrimPrefix(value, []byte("hello")))
    	case string:
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Apr 21 14:09:38 GMT 2023
    - 7.6K bytes
    - Viewed (0)
  6. interfaces.go

    type GetDBConnector interface {
    	GetDBConn() (*sql.DB, error)
    }
    
    // Rows rows interface
    type Rows interface {
    	Columns() ([]string, error)
    	ColumnTypes() ([]*sql.ColumnType, error)
    	Next() bool
    	Scan(dest ...interface{}) error
    	Err() error
    	Close() error
    }
    
    type ErrorTranslator interface {
    	Translate(err error) error
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Sat Aug 19 13:33:31 GMT 2023
    - 2.2K bytes
    - Viewed (0)
  7. callbacks/update.go

    					dest := db.Statement.Dest
    					db.Statement.Dest = db.Statement.ReflectValue.Addr().Interface()
    					gorm.Scan(rows, db, mode)
    					db.Statement.Dest = dest
    					db.AddError(rows.Close())
    				}
    			} else {
    				result, err := db.Statement.ConnPool.ExecContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 05:44:55 GMT 2024
    - 9.4K bytes
    - Viewed (1)
  8. scan.go

    		field.NewValuePool.Put(values[idx])
    	}
    }
    
    // ScanMode scan data mode
    type ScanMode uint8
    
    // scan modes
    const (
    	ScanInitialized         ScanMode = 1 << 0 // 1
    	ScanUpdate              ScanMode = 1 << 1 // 2
    	ScanOnConflictDoNothing ScanMode = 1 << 2 // 4
    )
    
    // Scan scan rows into db statement
    func Scan(rows Rows, db *DB, mode ScanMode) {
    	var (
    		columns, _          = rows.Columns()
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Mar 15 06:14:48 GMT 2024
    - 9.8K bytes
    - Viewed (0)
  9. schema/serializer.go

    	return string(result), err
    }
    
    // UnixSecondSerializer json serializer
    type UnixSecondSerializer struct{}
    
    // Scan implements serializer interface
    func (UnixSecondSerializer) Scan(ctx context.Context, field *Field, dst reflect.Value, dbValue interface{}) (err error) {
    	t := sql.NullTime{}
    	if err = t.Scan(dbValue); err == nil && t.Valid {
    		err = field.Set(ctx, dst, t.Time.Unix())
    	}
    
    	return
    }
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 08:28:46 GMT 2024
    - 4.6K bytes
    - Viewed (0)
  10. tests/benchmark_test.go

    }
    
    func BenchmarkScan(b *testing.B) {
    	user := *GetUser("scan", Config{})
    	DB.Create(&user)
    
    	var u User
    	b.ResetTimer()
    	for x := 0; x < b.N; x++ {
    		DB.Raw("select * from users where id = ?", user.ID).Scan(&u)
    	}
    }
    
    func BenchmarkScanSlice(b *testing.B) {
    	DB.Exec("delete from users")
    	for i := 0; i < 10_000; i++ {
    		user := *GetUser(fmt.Sprintf("scan-%d", i), Config{})
    		DB.Create(&user)
    	}
    
    	var u []User
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Jun 01 03:50:57 GMT 2022
    - 1.5K bytes
    - Viewed (0)
Back to top