Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 26 for utils (0.15 sec)

  1. callbacks/query.go

    							nestedAlias := utils.NestedRelationName(parentTableName, rel.Name)
    							if _, ok := specifiedRelationsName[nestedAlias]; !ok {
    								fromClause.Joins = append(fromClause.Joins, genJoinClause(join.JoinType, parentTableName, rel))
    								specifiedRelationsName[nestedAlias] = nil
    							}
    
    							if parentTableName != clause.CurrentTable {
    								parentTableName = utils.NestedRelationName(parentTableName, rel.Name)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Jan 29 03:34:57 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  2. callbacks/associations.go

    package callbacks
    
    import (
    	"reflect"
    	"strings"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    func SaveBeforeAssociations(create bool) func(db *gorm.DB) {
    	return func(db *gorm.DB) {
    		if db.Error == nil && db.Statement.Schema != nil {
    			selectColumns, restricted := db.Statement.SelectAndOmitColumns(create, !create)
    
    			// Save Belongs To associations
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Apr 11 03:06:13 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  3. chainable_api.go

    package gorm
    
    import (
    	"fmt"
    	"regexp"
    	"strings"
    
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/utils"
    )
    
    // Model specify the model you would like to run db operations
    //
    //	// update all users's name to `hello`
    //	db.Model(&User{}).Update("name", "hello")
    //	// if user's primary key is non-blank, will use it as condition, then will only update that user's name to `hello`
    //	db.Model(&user).Update("name", "hello")
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  4. tests/upsert_test.go

    package tests_test
    
    import (
    	"regexp"
    	"testing"
    	"time"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestUpsert(t *testing.T) {
    	lang := Language{Code: "upsert", Name: "Upsert"}
    	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"}
    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)
  5. tests/hooks_test.go

    package tests_test
    
    import (
    	"errors"
    	"reflect"
    	"strings"
    	"testing"
    
    	"gorm.io/gorm"
    	. "gorm.io/gorm/utils/tests"
    )
    
    type Product struct {
    	gorm.Model
    	Name                  string
    	Code                  string
    	Price                 float64
    	AfterFindCallTimes    int64
    	BeforeCreateCallTimes int64
    	AfterCreateCallTimes  int64
    	BeforeUpdateCallTimes int64
    	AfterUpdateCallTimes  int64
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  6. callbacks/create.go

    package callbacks
    
    import (
    	"fmt"
    	"reflect"
    	"strings"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // BeforeCreate before create hooks
    func BeforeCreate(db *gorm.DB) {
    	if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeCreate) {
    		callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 08 03:29:55 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  7. tests/table_test.go

    package tests_test
    
    import (
    	"regexp"
    	"sync"
    	"testing"
    
    	"gorm.io/driver/postgres"
    	"gorm.io/gorm"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils/tests"
    	. "gorm.io/gorm/utils/tests"
    )
    
    type UserWithTable struct {
    	gorm.Model
    	Name string
    }
    
    func (UserWithTable) TableName() string {
    	return "gorm.user"
    }
    
    func TestTable(t *testing.T) {
    	dryDB := DB.Session(&gorm.Session{DryRun: true})
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  8. finisher_api.go

    package gorm
    
    import (
    	"database/sql"
    	"errors"
    	"fmt"
    	"reflect"
    	"strings"
    
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/logger"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // Create inserts value, returning the inserted data's primary key in value's id
    func (db *DB) Create(value interface{}) (tx *DB) {
    	if db.CreateBatchSize > 0 {
    		return db.CreateInBatches(value, db.CreateBatchSize)
    	}
    
    	tx = db.getInstance()
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
  9. schema/field.go

    		Readable:               true,
    		PrimaryKey:             utils.CheckTruth(tagSetting["PRIMARYKEY"], tagSetting["PRIMARY_KEY"]),
    		AutoIncrement:          utils.CheckTruth(tagSetting["AUTOINCREMENT"]),
    		HasDefaultValue:        utils.CheckTruth(tagSetting["AUTOINCREMENT"]),
    		NotNull:                utils.CheckTruth(tagSetting["NOT NULL"], tagSetting["NOTNULL"]),
    		Unique:                 utils.CheckTruth(tagSetting["UNIQUE"]),
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 32K bytes
    - Viewed (1)
  10. tests/update_test.go

    package tests_test
    
    import (
    	"errors"
    	"regexp"
    	"sort"
    	"strings"
    	"testing"
    	"time"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/utils"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestUpdate(t *testing.T) {
    	var (
    		users = []*User{
    			GetUser("update-1", Config{}),
    			GetUser("update-2", Config{}),
    			GetUser("update-3", Config{}),
    		}
    		user          = users[1]
    		lastUpdatedAt time.Time
    	)
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
Back to top