Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 25 for It (0.15 sec)

  1. callbacks.go

    			if errors.Is(err, schema.ErrUnsupportedDataType) && stmt.Table == "" && stmt.TableExpr == nil {
    				db.AddError(fmt.Errorf("%w: Table not set, please set it like: db.Model(&user) or db.Table(\"users\")", err))
    			} else {
    				db.AddError(err)
    			}
    		}
    	}
    
    	// assign stmt.ReflectValue
    	if stmt.Dest != nil {
    		stmt.ReflectValue = reflect.ValueOf(stmt.Dest)
    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)
  2. tests/create_test.go

    	}
    }
    
    func TestCreateNilPointer(t *testing.T) {
    	var user *User
    
    	err := DB.Create(user).Error
    	if err == nil || err != gorm.ErrInvalidValue {
    		t.Fatalf("it is not ErrInvalidValue")
    	}
    }
    
    func TestFirstOrCreateRowsAffected(t *testing.T) {
    	user := User{Name: "TestFirstOrCreateRowsAffected"}
    
    	res := DB.FirstOrCreate(&user, "name = ?", user.Name)
    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)
  3. logger/sql.go

    		return true
    	case reflect.Float32, reflect.Float64:
    		return true
    	default:
    		return false
    	}
    }
    
    // ExplainSQL generate SQL string with given parameters, the generated SQL is expected to be used in logger, execute it might introduce a SQL injection vulnerability
    func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string {
    	var (
    		convertParams func(interface{}, int)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 21 08:00:02 GMT 2024
    - 5K bytes
    - Viewed (0)
  4. schema/naming.go

    	if ns.SingularTable {
    		return ns.TablePrefix + ns.toDBName(str)
    	}
    	return ns.TablePrefix + inflection.Plural(ns.toDBName(str))
    }
    
    // SchemaName generate schema name from table name, don't guarantee it is the reverse value of TableName
    func (ns NamingStrategy) SchemaName(table string) string {
    	table = strings.TrimPrefix(table, ns.TablePrefix)
    
    	if ns.SingularTable {
    		return ns.toSchemaName(table)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  5. callbacks/query.go

    	}
    }
    
    func AfterQuery(db *gorm.DB) {
    	// clear the joins after query because preload need it
    	db.Statement.Joins = nil
    	if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && db.Statement.Schema.AfterFind && db.RowsAffected > 0 {
    		callMethod(db, func(value interface{}, tx *gorm.DB) bool {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Jan 29 03:34:57 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  6. migrator/migrator.go

    }
    
    // DropView drop view
    func (m Migrator) DropView(name string) error {
    	return m.DB.Exec("DROP VIEW IF EXISTS ?", clause.Table{Name: name}).Error
    }
    
    // GuessConstraintAndTable guess statement's constraint and it's table based on name
    //
    // Deprecated: use GuessConstraintInterfaceAndTable instead.
    func (m Migrator) GuessConstraintAndTable(stmt *gorm.Statement, name string) (*schema.Constraint, *schema.CheckConstraint, string) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  7. callbacks/associations.go

    	}
    
    	if len(omits) > 0 {
    		tx = tx.Omit(omits...)
    	}
    
    	return db.AddError(tx.Create(values).Error)
    }
    
    // check association values has been saved
    // if values kind is Struct, check it has been saved
    // if values kind is Slice/Array, check all items have been saved
    var visitMapStoreKey = "gorm:saved_association_map"
    
    func checkAssociationsSaved(db *gorm.DB, values reflect.Value) bool {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Apr 11 03:06:13 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  8. chainable_api.go

    )
    
    // 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")
    func (db *DB) Model(value interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Model = value
    	return
    }
    
    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)
  9. model.go

    package gorm
    
    import "time"
    
    // Model a basic GoLang struct which includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt
    // It may be embedded into your model or you may build your own model without it
    //
    //	type User struct {
    //	  gorm.Model
    //	}
    type Model struct {
    	ID        uint `gorm:"primarykey"`
    	CreatedAt time.Time
    	UpdatedAt time.Time
    	DeletedAt DeletedAt `gorm:"index"`
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:06:43 GMT 2023
    - 396 bytes
    - Viewed (0)
  10. tests/main_test.go

    package tests_test
    
    import (
    	"testing"
    
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestExceptionsWithInvalidSql(t *testing.T) {
    	if name := DB.Dialector.Name(); name == "sqlserver" {
    		t.Skip("skip sqlserver due to it will raise data race for invalid sql")
    	}
    
    	var columns []string
    	if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
    		t.Errorf("Should got error with invalid SQL")
    	}
    
    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)
Back to top