Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for TestOmitWithAllFields (0.09 sec)

  1. tests/query_test.go

    	}
    
    	if result.Name != "" || result.Age != 20 {
    		t.Errorf("User Name should be omitted, got %v, Age should be ok, got %v", result.Name, result.Age)
    	}
    }
    
    func TestOmitWithAllFields(t *testing.T) {
    	user := User{Name: "OmitUser1", Age: 20}
    	DB.Save(&user)
    
    	var userResult User
    	DB.Session(&gorm.Session{QueryFields: true}).Where("users.name = ?", user.Name).Omit("name").Find(&userResult)
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Jun 24 09:42:59 UTC 2024
    - 50.4K bytes
    - Viewed (0)
Back to top