Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for Crooks (0.15 sec)

  1. tests/hooks_test.go

    	product2 := Product3{Name: "Product", Price: 0}
    	DB.Session(&gorm.Session{SkipHooks: true}).Create(&product2)
    
    	if product2.Price != 0 {
    		t.Errorf("invalid price after create without hooks, got %+v", product2)
    	}
    }
    
    func TestHooksForSlice(t *testing.T) {
    	DB.Migrator().DropTable(&Product3{})
    	DB.AutoMigrate(&Product3{})
    
    	products := []*Product3{
    		{Name: "Product-1", Price: 100},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  2. callbacks/create.go

    package callbacks
    
    import (
    	"fmt"
    	"reflect"
    	"strings"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // BeforeCreate before create hooks
    func BeforeCreate(db *gorm.DB) {
    	if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeCreate) {
    		callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 08 03:29:55 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  3. tests/transaction_test.go

    			return tx2.Scan(&User{}).Error
    		})
    	})
    
    	if err != nil {
    		t.Error(err)
    	}
    
    	// method with hooks
    	err = DB.Transaction(func(tx1 *gorm.DB) error {
    		// callMethod do
    		tx2 := tx1.Find(&User{}).Session(&gorm.Session{NewDB: true})
    		// trx in hooks
    		return tx2.Transaction(func(tx3 *gorm.DB) error {
    			return tx3.Where("user_id", user.ID).Delete(&Account{}).Error
    		})
    	})
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  4. statement.go

    				// looks like a where condition
    				return []clause.Expression{clause.Expr{SQL: s, Vars: args}}
    			}
    
    			if len(args) > 0 && strings.Contains(s, "@") {
    				// looks like a named query
    				return []clause.Expression{clause.NamedExpr{SQL: s, Vars: args}}
    			}
    
    			if strings.Contains(strings.TrimSpace(s), " ") {
    				// looks like a where condition
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
  5. schema/schema.go

    	if field, ok := schema.FieldsByDBName[name]; ok {
    		return field
    	}
    	if field, ok := schema.FieldsByName[name]; ok {
    		return field
    	}
    	return nil
    }
    
    // LookUpFieldByBindName looks for the closest field in the embedded struct.
    //
    //	type Struct struct {
    //		Embedded struct {
    //			ID string // is selected by LookUpFieldByBindName([]string{"Embedded", "ID"}, "ID")
    //		}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Oct 10 06:50:29 GMT 2023
    - 13.7K bytes
    - Viewed (0)
Back to top