Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 25 for soft (0.18 sec)

  1. soft_delete.go

    func (sd SoftDeleteQueryClause) Build(clause.Builder) {
    }
    
    func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause) {
    }
    
    func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) {
    	if _, ok := stmt.Clauses["soft_delete_enabled"]; !ok && !stmt.Statement.Unscoped {
    		if c, ok := stmt.Clauses["WHERE"]; ok {
    			if where, ok := c.Expression.(clause.Where); ok && len(where.Exprs) >= 1 {
    				for _, expr := range where.Exprs {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 4.5K bytes
    - Viewed (0)
  2. tests/soft_delete_test.go

    		t.Errorf("Count soft deleted record, expects: %v, got: %v", 1, count)
    	}
    
    	if DB.Model(&User{}).Select("age").Where("name = ?", user.Name).Scan(&age).Error != nil || age != user.Age {
    		t.Errorf("Age soft deleted record, expects: %v, got: %v", 0, age)
    	}
    
    	if err := DB.Delete(&user).Error; err != nil {
    		t.Fatalf("No error should happen when soft delete user, but got %v", err)
    	}
    
    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)
  3. tests/joins_table_test.go

    	}
    
    	if DB.Unscoped().Find(&[]PersonAddress{}, "person_id = ?", person.ID).RowsAffected != 2 {
    		t.Fatalf("Should found soft deleted addresses with unscoped")
    	}
    
    	if DB.Unscoped().Model(&person).Association("Addresses").Count() != 2 {
    		t.Fatalf("Should found soft deleted addresses with unscoped")
    	}
    
    	DB.Model(&person).Association("Addresses").Clear()
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Sep 10 13:46:18 GMT 2020
    - 3.5K bytes
    - Viewed (0)
  4. finisher_api.go

    	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)
  5. clause/set_test.go

    package clause_test
    
    import (
    	"fmt"
    	"sort"
    	"strings"
    	"testing"
    
    	"gorm.io/gorm/clause"
    )
    
    func TestSet(t *testing.T) {
    	results := []struct {
    		Clauses []clause.Interface
    		Result  string
    		Vars    []interface{}
    	}{
    		{
    			[]clause.Interface{
    				clause.Update{},
    				clause.Set([]clause.Assignment{{clause.PrimaryColumn, 1}}),
    			},
    			"UPDATE `users` SET `users`.`id`=?",
    			[]interface{}{1},
    		},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.4K bytes
    - Viewed (0)
  6. tests/joins_test.go

    	} else if len(users2) != len(users) {
    		t.Fatalf("Failed to load join users, got: %v, expect: %v", len(users2), len(users))
    	}
    
    	sort.Slice(users2, func(i, j int) bool {
    		return users2[i].ID > users2[j].ID
    	})
    
    	sort.Slice(users, func(i, j int) bool {
    		return users[i].ID > users[j].ID
    	})
    
    	for idx, user := range users {
    		CheckUser(t, user, users2[idx])
    	}
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  7. tests/count_test.go

    package tests_test
    
    import (
    	"fmt"
    	"regexp"
    	"sort"
    	"strings"
    	"testing"
    
    	"gorm.io/gorm"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestCountWithGroup(t *testing.T) {
    	DB.Create([]Company{
    		{Name: "company_count_group_a"},
    		{Name: "company_count_group_a"},
    		{Name: "company_count_group_a"},
    		{Name: "company_count_group_b"},
    		{Name: "company_count_group_c"},
    	})
    
    	var count1 int64
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  8. callbacks.go

    package gorm
    
    import (
    	"context"
    	"errors"
    	"fmt"
    	"reflect"
    	"sort"
    	"time"
    
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    func initializeCallbacks(db *DB) *callbacks {
    	return &callbacks{
    		processors: map[string]*processor{
    			"create": {db: db},
    			"query":  {db: db},
    			"update": {db: db},
    			"delete": {db: db},
    			"row":    {db: db},
    			"raw":    {db: db},
    		},
    	}
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 26 03:33:36 GMT 2024
    - 8.6K bytes
    - Viewed (1)
  9. chainable_api.go

    	tx.Statement.assigns = attrs
    	return
    }
    
    // Unscoped disables the global scope of soft deletion in a query.
    // 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)
    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)
  10. callbacks/helper.go

    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)
    				withCondition = len(whereClause.Exprs) > 1
    			}
    		}
    		if !withCondition {
    			db.AddError(gorm.ErrMissingWhereClause)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 14 12:32:57 GMT 2022
    - 3.7K bytes
    - Viewed (0)
Back to top