Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 49 for Deleted (0.16 sec)

  1. tests/soft_delete_test.go

    		t.Fatalf("user's deleted at is zero")
    	}
    
    	sql := DB.Session(&gorm.Session{DryRun: true}).Delete(&user).Statement.SQL.String()
    	if !regexp.MustCompile(`UPDATE .users. SET .deleted_at.=.* WHERE .users.\..id. = .* AND .users.\..deleted_at. IS NULL`).MatchString(sql) {
    		t.Fatalf("invalid sql generated, got %v", sql)
    	}
    
    	sql = DB.Session(&gorm.Session{DryRun: true}).Table("user u").Select("name").Find(&User{}).Statement.SQL.String()
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 5.7K bytes
    - Viewed (0)
  2. tests/connpool_test.go

    			"SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?",
    			"INSERT INTO `users` (`created_at`,`updated_at`,`deleted_at`,`name`,`age`,`birthday`,`company_id`,`manager_id`,`active`) VALUES (?,?,?,?,?,?,?,?,?)",
    			"SELECT * FROM `users` WHERE name = ? AND `users`.`deleted_at` IS NULL ORDER BY `users`.`id` LIMIT ?",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Feb 06 02:54:40 GMT 2024
    - 5.5K bytes
    - Viewed (0)
  3. tests/table_test.go

    	if !regexp.MustCompile("SELECT \\* FROM \\(SELECT .name. FROM .users. WHERE .users.\\..deleted_at. IS NULL\\) as u, \\(SELECT .name. FROM .pets. WHERE .pets.\\..deleted_at. IS NULL\\) as p WHERE .u.\\..deleted_at. IS NULL").MatchString(r.Statement.SQL.String()) {
    		t.Errorf("Table with escape character, got %v", r.Statement.SQL.String())
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  4. logger/sql_test.go

    			NumericRegexp: nil,
    			Vars:          []interface{}{"jinzhu", 1, 999.99, true, []byte("12345"), tt, &tt, nil, "w@g.\"com", myrole, pwd},
    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)
  5. tests/main_test.go

    	if count1 <= 0 {
    		t.Errorf("Should find some users")
    	}
    
    	if DB.Where("name = ?", "jinzhu; delete * from users").First(&User{}).Error == nil {
    		t.Errorf("Should got error with invalid SQL")
    	}
    
    	DB.Model(&User{}).Count(&count2)
    	if count1 != count2 {
    		t.Errorf("No user should not be deleted by invalid SQL")
    	}
    }
    
    func TestSetAndGet(t *testing.T) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 24 01:31:58 GMT 2022
    - 1.4K bytes
    - Viewed (0)
  6. chainable_api.go

    // By default, GORM uses soft deletion, marking records as "deleted"
    // by setting a timestamp on a specific field (e.g., `deleted_at`).
    // Unscoped allows queries to include records marked as deleted,
    // overriding the soft deletion behavior.
    // Example:
    //    var users []User
    //    db.Unscoped().Find(&users)
    //    // Retrieves all users, including deleted ones.
    func (db *DB) Unscoped() (tx *DB) {
    	tx = db.getInstance()
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  7. tests/hooks_test.go

    	}
    
    	p5 := Product{Code: "after_delete_error", Price: 100}
    	DB.Save(&p5)
    	if err := DB.First(&Product{}, "code = ?", "after_delete_error").Error; err != nil {
    		t.Fatalf("Record should be found")
    	}
    
    	DB.Delete(&p5)
    	if err := DB.First(&Product{}, "code = ?", "after_delete_error").Error; err != nil {
    		t.Fatalf("Record shouldn't be deleted because of an error happened in after delete callback")
    	}
    }
    
    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)
  8. finisher_api.go

    	tx.Statement.SkipHooks = true
    	return tx.callbacks.Update().Execute(tx)
    }
    
    // Delete deletes value matching given conditions. If value contains primary key it is included in the conditions. If
    // value includes a deleted_at field, then Delete performs a soft delete instead by setting deleted_at with the current
    // time if null.
    func (db *DB) Delete(value interface{}, conds ...interface{}) (tx *DB) {
    	tx = db.getInstance()
    	if len(conds) > 0 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
  9. tests/migrate_test.go

    	}
    
    	ids := make([]int64, 0, len(rows))
    	for _, row := range rows {
    		ids = append(ids, row.ID)
    	}
    	lastID := ids[len(ids)-1]
    
    	if err := DB.Where("id IN (?)", ids).Delete(&AutoIncrementStruct{}).Error; err != nil {
    		t.Fatalf("delete auto_increment_struct fail, err: %v", err)
    	}
    
    	newRow := &AutoIncrementStruct{}
    	if err := DB.Create(newRow).Error; err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  10. tests/associations_has_many_test.go

    	// Delete
    	if err := DB.Model(&user2).Association("Pets").Delete(&Pet{}); err != nil {
    		t.Fatalf("Error happened when delete pet, got %v", err)
    	}
    	AssertAssociationCount(t, user2, "Pets", 1, "after delete non-existing data")
    
    	if err := DB.Model(&user2).Association("Pets").Delete(&pet2); err != nil {
    		t.Fatalf("Error happened when delete Pets, got %v", err)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
Back to top