Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 319 for db (0.13 sec)

  1. callbacks/row.go

    import (
    	"gorm.io/gorm"
    )
    
    func RowQuery(db *gorm.DB) {
    	if db.Error == nil {
    		BuildQuerySQL(db)
    		if db.DryRun || db.Error != nil {
    			return
    		}
    
    		if isRows, ok := db.Get("rows"); ok && isRows.(bool) {
    			db.Statement.Settings.Delete("rows")
    			db.Statement.Dest, db.Error = db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
    		} else {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Feb 08 05:40:41 GMT 2023
    - 581 bytes
    - Viewed (0)
  2. tests/associations_test.go

    	parent := Parent{}
    	DB.Create(&parent)
    
    	child := Child{ParentID: &parent.ID, Parent: &parent}
    	DB.Create(&child)
    
    	parent.FavChildID = child.ID
    	parent.FavChild = &child
    	DB.Save(&parent)
    
    	var parent1 Parent
    	DB.First(&parent1, parent.ID)
    	AssertObjEqual(t, parent, parent1, "ID", "FavChildID")
    
    	// Save and Updates is the same
    	DB.Updates(&parent)
    	DB.First(&parent1, parent.ID)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Feb 08 08:29:09 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  3. association.go

    type Association struct {
    	DB           *DB
    	Relationship *schema.Relationship
    	Unscope      bool
    	Error        error
    }
    
    func (db *DB) Association(column string) *Association {
    	association := &Association{DB: db}
    	table := db.Statement.Table
    
    	if err := db.Statement.Parse(db.Statement.Model); err == nil {
    		db.Statement.Table = table
    		association.Relationship = db.Statement.Schema.Relationships.Relations[column]
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu May 04 11:30:45 GMT 2023
    - 21.2K bytes
    - Viewed (0)
  4. tests/connpool_test.go

    }
    
    type wrapperConnPool struct {
    	db     *sql.DB
    	got    []string
    	expect []string
    }
    
    func (c *wrapperConnPool) Ping() error {
    	return c.db.Ping()
    }
    
    // If you use BeginTx returned *sql.Tx as shown below then you can't record queries in a transaction.
    //
    //	func (c *wrapperConnPool) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) {
    //		 return c.db.BeginTx(ctx, opts)
    //	}
    //
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Feb 06 02:54:40 GMT 2024
    - 5.5K bytes
    - Viewed (0)
  5. tests/postgres_test.go

    	}
    
    	if err := DB.Exec("CREATE EXTENSION IF NOT EXISTS pgcrypto;").Error; err != nil {
    		t.Errorf("Failed to create extension pgcrypto, got error %v", err)
    	}
    
    	DB.Migrator().DropTable(&Harumph{})
    
    	if err := DB.AutoMigrate(&Harumph{}); err != nil {
    		t.Fatalf("Failed to migrate for uuid default value, got error: %v", err)
    	}
    
    	harumph := Harumph{}
    	if err := DB.Create(&harumph).Error; err == nil {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Oct 08 09:16:32 GMT 2022
    - 6.4K bytes
    - Viewed (3)
  6. tests/associations_many2many_test.go

    	DB.Create(&languages2_1)
    	DB.Create(&languages2_2)
    	DB.Create(&languages2_3)
    
    	// Replace
    	DB.Model(&users).Association("Languages").Replace(&languages2_1, &languages2_2, languages2_3)
    
    	AssertAssociationCount(t, users, "Languages", 5, "After Replace")
    
    	// Delete
    	if err := DB.Model(&users).Association("Languages").Delete(&users[2].Languages); err != nil {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 13.2K bytes
    - Viewed (0)
  7. tests/sql_builder_test.go

    	// after model changed
    	if DB.Statement.DryRun || DB.DryRun {
    		t.Fatal("Failed expect DB.DryRun and DB.Statement.ToSQL to be false")
    	}
    
    	if DB.Statement.SQL.String() != "" {
    		t.Fatal("Failed expect DB.Statement.SQL to be empty")
    	}
    
    	// first
    	sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
  8. tests/tests_test.go

    		if dbDSN == "" {
    			dbDSN = sqlserverDSN
    		}
    		db, err = gorm.Open(sqlserver.Open(dbDSN), cfg)
    	case "tidb":
    		log.Println("testing tidb...")
    		if dbDSN == "" {
    			dbDSN = tidbDSN
    		}
    		db, err = gorm.Open(mysql.Open(dbDSN), cfg)
    	default:
    		log.Println("testing sqlite3...")
    		db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db")), cfg)
    		if err == nil {
    			db.Exec("PRAGMA foreign_keys = ON")
    		}
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 3.3K bytes
    - Viewed (1)
  9. tests/upsert_test.go

    	if err := DB.Clauses(clause.OnConflict{DoNothing: true}).Create(&lang).Error; err != nil {
    		t.Fatalf("failed to upsert, got %v", err)
    	}
    
    	lang2 := Language{Code: "upsert", Name: "Upsert"}
    	if err := DB.Clauses(clause.OnConflict{DoNothing: true}).Create(&lang2).Error; err != nil {
    		t.Fatalf("failed to upsert, got %v", err)
    	}
    
    	var langs []Language
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  10. callbacks/helper.go

    				return true, 0
    			}
    			return true, gorm.ScanUpdate
    		}
    	}
    	return false, 0
    }
    
    func checkMissingWhereConditions(db *gorm.DB) {
    	if !db.AllowGlobalUpdate && db.Error == nil {
    		where, withCondition := db.Statement.Clauses["WHERE"]
    		if withCondition {
    			if _, withSoftDelete := db.Statement.Clauses["soft_delete_enabled"]; withSoftDelete {
    				whereClause, _ := where.Expression.(clause.Where)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 14 12:32:57 GMT 2022
    - 3.7K bytes
    - Viewed (0)
Back to top