Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 22 for Records (0.17 sec)

  1. tests/create_test.go

    	}
    
    	if _, ok := records[0]["@id"]; ok && fmt.Sprint(res2["id"]) != fmt.Sprint(records[0]["@id"]) {
    		t.Errorf("failed to create data from map with table, @id != id, got %v, expect %v", res2["id"], records[0]["@id"])
    	}
    
    	if _, ok := records[1]["id"]; ok && fmt.Sprint(res3["id"]) != fmt.Sprint(records[1]["@id"]) {
    		t.Errorf("failed to create data from map with table, @id != id")
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  2. chainable_api.go

    	return
    }
    
    // Assign provide attributes used in [FirstOrCreate] or [FirstOrInit]
    //
    // Assign adds attributes even if the record is found. If using FirstOrCreate, this means that
    // records will be updated even if they are found.
    //
    //	// assign an email regardless of if the record is not found
    //	db.Where(User{Name: "non_existing"}).Assign(User{Email: "******@****.***"}).FirstOrInit(&user)
    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)
  3. logger/logger.go

    package logger
    
    import (
    	"context"
    	"errors"
    	"fmt"
    	"io"
    	"log"
    	"os"
    	"time"
    
    	"gorm.io/gorm/utils"
    )
    
    // ErrRecordNotFound record not found error
    var ErrRecordNotFound = errors.New("record not found")
    
    // Colors
    const (
    	Reset       = "\033[0m"
    	Red         = "\033[31m"
    	Green       = "\033[32m"
    	Yellow      = "\033[33m"
    	Blue        = "\033[34m"
    	Magenta     = "\033[35m"
    	Cyan        = "\033[36m"
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Nov 07 02:19:41 GMT 2023
    - 5.8K bytes
    - Viewed (0)
  4. finisher_api.go

    	}
    	return
    }
    
    // FirstOrCreate finds the first matching record, otherwise if not found creates a new instance with given conds.
    // Each conds must be a struct or map.
    //
    // Using FirstOrCreate in conjunction with Assign will result in an update to the database even if the record exists.
    //
    //	// assign an email if the record is not found
    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. tests/soft_delete_test.go

    		t.Errorf("Can't find a soft deleted record")
    	}
    
    	count = 0
    	if DB.Model(&User{}).Where("name = ?", user.Name).Count(&count).Error != nil || count != 0 {
    		t.Errorf("Count soft deleted record, expects: %v, got: %v", 0, count)
    	}
    
    	age = 0
    	if DB.Model(&User{}).Select("age").Where("name = ?", user.Name).Scan(&age).Error != nil || age != 0 {
    		t.Errorf("Age soft deleted record, expects: %v, got: %v", 0, age)
    	}
    
    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)
  6. tests/connpool_test.go

    	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)
    //	}
    //
    // You should use BeginTx returned gorm.Tx which could wrap *sql.Tx then you can record all queries.
    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)
  7. tests/named_argument_test.go

    		t.Errorf("should return record not found error, but got %v", err)
    	}
    
    	DB.Delete(&namedUser)
    
    	var result8 NamedUser
    	if err := DB.Where("name1 = @name OR name2 = @name", map[string]interface{}{"name": "jinzhu-new"}).First(&result8).Error; err == nil || !errors.Is(err, gorm.ErrRecordNotFound) {
    		t.Errorf("should return record not found error, but got %v", err)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Dec 21 11:50:00 GMT 2021
    - 2.7K bytes
    - Viewed (0)
  8. tests/joins_test.go

    		Joins("JOIN languages ON languages.code = user_speaks.language_code").
    		Joins("LEFT OUTER JOIN pets ON pets.user_id = users.id").Find(&results)
    
    	if len(results) == 0 {
    		t.Fatalf("no record find")
    	} else if results[0].Pet.UserID == nil || *(results[0].Pet.UserID) != user.ID {
    		t.Fatalf("wrong user id in pet")
    	} else if results[0].Pet.Name != user.Pets[0].Name {
    		t.Fatalf("wrong pet name")
    	}
    }
    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)
  9. tests/hooks_test.go

    	}
    
    	if DB.Where("Code = ?", "unique_code").First(&p).Error == nil {
    		t.Fatalf("Can't find a deleted record")
    	}
    
    	beforeCallTimes := p.AfterFindCallTimes
    	if DB.Where("Code = ?", "unique_code").Find(&p).Error != nil {
    		t.Fatalf("Find don't raise error when record not found")
    	}
    
    	if p.AfterFindCallTimes != beforeCallTimes {
    		t.Fatalf("AfterFind should not be called")
    	}
    }
    
    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)
  10. tests/update_test.go

    		t.Errorf("should only update one record, but got %v", rowsAffected)
    	}
    
    	if rowsAffected := DB.Model(users).Where("age > 0").Update("name", "jinzhu").RowsAffected; rowsAffected != 3 {
    		t.Errorf("should only update one record, but got %v", rowsAffected)
    	}
    }
    
    func TestUpdates(t *testing.T) {
    	users := []*User{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
Back to top