Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for Background (0.3 sec)

  1. tests/transaction_test.go

    			})
    		}); err != nil {
    			t.Fatalf("prepare statement and nested transcation coexist" + err.Error())
    		}
    	})
    }
    
    func TestCancelTransaction(t *testing.T) {
    	ctx := context.Background()
    	ctx, cancelFunc := context.WithCancel(ctx)
    	cancelFunc()
    
    	user := *GetUser("cancel_transaction", Config{})
    	DB.Create(&user)
    
    	err := DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  2. schema/field_test.go

    		"updated_at": nil,
    		"deleted_at": time.Now(),
    		"age":        20,
    		"birthday":   time.Now(),
    		"active":     f,
    	}
    
    	for k, v := range newValues {
    		if err := userSchema.FieldsByDBName[k].Set(context.Background(), reflectValue, v); err != nil {
    			t.Errorf("no error should happen when assign value to field %v, but got %v", k, err)
    		}
    	}
    	newValues["updated_at"] = time.Time{}
    	newValues["active"] = false
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Feb 19 09:02:53 GMT 2022
    - 12.7K bytes
    - Viewed (0)
  3. tests/scopes_test.go

    	if result.RowsAffected != 2 {
    		t.Errorf("Should found two users's name in 1, 2, but got %v", result.RowsAffected)
    	}
    
    	var maxId int64
    	userTable := func(db *gorm.DB) *gorm.DB {
    		return db.WithContext(context.Background()).Table("users")
    	}
    	if err := DB.Scopes(userTable).Select("max(id)").Scan(&maxId).Error; err != nil {
    		t.Errorf("select max(id)")
    	}
    }
    
    func TestComplexScopes(t *testing.T) {
    	tests := []struct {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 3.3K bytes
    - Viewed (0)
  4. schema/schema_helper_test.go

    func checkField(t *testing.T, s *schema.Schema, value reflect.Value, values map[string]interface{}) {
    	for k, v := range values {
    		t.Run("CheckField/"+k, func(t *testing.T) {
    			fv, _ := s.FieldsByDBName[k].ValueOf(context.Background(), value)
    			tests.AssertEqual(t, v, fv)
    		})
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  5. migrator/migrator.go

    		}
    		beDependedOn := map[*schema.Schema]bool{}
    		// support for special table name
    		if err := dep.ParseWithSpecialTableName(value, m.DB.Statement.Table); err != nil {
    			m.DB.Logger.Error(context.Background(), "failed to parse value %#v, got error %v", value, err)
    		}
    		if _, ok := parsedSchemas[dep.Statement.Schema]; ok {
    			return
    		}
    		parsedSchemas[dep.Statement.Schema] = true
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  6. schema/schema.go

    			switch methodValue.Type().String() {
    			case "func(*gorm.DB) error": // TODO hack
    				reflect.Indirect(reflect.ValueOf(schema)).FieldByName(string(cbName)).SetBool(true)
    			default:
    				logger.Default.Warn(context.Background(), "Model %v don't match %vInterface, should be `%v(*gorm.DB) error`. Please see https://gorm.io/docs/hooks.html", schema, cbName, cbName)
    			}
    		}
    	}
    
    	// Cache the schema
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 06:50:29 GMT 2023
    - 13.7K bytes
    - Viewed (0)
  7. gorm.go

    		DB:       db,
    		ConnPool: db.ConnPool,
    		Context:  context.Background(),
    		Clauses:  map[string]clause.Clause{},
    	}
    
    	if err == nil && !config.DisableAutomaticPing {
    		if pinger, ok := db.ConnPool.(interface{ Ping() error }); ok {
    			err = pinger.Ping()
    		}
    	}
    
    	if err != nil {
    		config.Logger.Error(context.Background(), "failed to initialize database, got error %v", err)
    	}
    
    	return
    }
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sun Aug 20 11:46:56 GMT 2023
    - 11.6K bytes
    - Viewed (0)
  8. callbacks.go

    	c.processor.db.Logger.Warn(context.Background(), "removing callback `%s` from %s\n", name, utils.FileWithLineNum())
    	c.name = name
    	c.remove = true
    	c.processor.callbacks = append(c.processor.callbacks, c)
    	return c.processor.compile()
    }
    
    func (c *callback) Replace(name string, fn func(*DB)) error {
    	c.processor.db.Logger.Info(context.Background(), "replacing callback `%s` from %s\n", name, utils.FileWithLineNum())
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Mar 26 03:33:36 GMT 2024
    - 8.6K bytes
    - Viewed (1)
  9. tests/prepared_stmt_test.go

    	if _, ok := tx.ConnPool.(*gorm.PreparedStmtDB); !ok {
    		t.Fatalf("should assign PreparedStatement Manager back to database when using PrepareStmt mode")
    	}
    
    	ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
    	defer cancel()
    	txCtx := tx.WithContext(ctx)
    
    	user := *GetUser("prepared_stmt", Config{})
    
    	txCtx.Create(&user)
    
    	var result1 User
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Mar 21 07:55:43 GMT 2024
    - 4K bytes
    - Viewed (0)
Back to top