Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 28 for primary (0.41 sec)

  1. tests/multi_primary_keys_test.go

    package tests_test
    
    import (
    	"reflect"
    	"sort"
    	"testing"
    
    	"gorm.io/gorm"
    	. "gorm.io/gorm/utils/tests"
    )
    
    type Blog struct {
    	ID         uint   `gorm:"primary_key"`
    	Locale     string `gorm:"primary_key"`
    	Subject    string
    	Body       string
    	Tags       []Tag `gorm:"many2many:blog_tags;"`
    	SharedTags []Tag `gorm:"many2many:shared_blog_tags;ForeignKey:id;References:id"`
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 12.8K bytes
    - Viewed (0)
  2. tests/update_test.go

    		}
    		CheckUser(t, last, *users[2])
    	}
    
    	if err := DB.Create(&users).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	} else if user.ID == 0 {
    		t.Fatalf("user's primary value should not zero, %v", user.ID)
    	} else if user.UpdatedAt.IsZero() {
    		t.Fatalf("user's updated at should not zero, %v", user.UpdatedAt)
    	}
    	lastUpdatedAt = user.UpdatedAt
    
    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)
  3. migrator/index.go

    func (idx Index) Name() string {
    	return idx.NameValue
    }
    
    // Columns return the columns of the index
    func (idx Index) Columns() []string {
    	return idx.ColumnList
    }
    
    // PrimaryKey returns the index is primary key or not.
    func (idx Index) PrimaryKey() (isPrimaryKey bool, ok bool) {
    	return idx.PrimaryKeyValue.Bool, idx.PrimaryKeyValue.Valid
    }
    
    // Unique returns whether the index is unique or not.
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Apr 11 02:32:46 GMT 2023
    - 1023 bytes
    - Viewed (0)
  4. callbacks/associations.go

    								}
    							}
    							cacheKey := utils.ToStringKey(relPrimaryValues...)
    							if len(relPrimaryValues) != len(rel.FieldSchema.PrimaryFields) || !identityMap[cacheKey] {
    								if cacheKey != "" { // has primary fields
    									identityMap[cacheKey] = true
    								}
    
    								distinctElems = reflect.Append(distinctElems, rv)
    							}
    						}
    					}
    
    					if elems.Len() > 0 {
    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)
  5. migrator/migrator.go

    					values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field))
    					createTableSQL += ","
    				}
    			}
    
    			if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 {
    				createTableSQL += "PRIMARY KEY ?,"
    				primaryKeys := make([]interface{}, 0, len(stmt.Schema.PrimaryFields))
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  6. schema/schema_helper_test.go

    					found = true
    				}
    			}
    
    			if idx == 0 {
    				if field != s.PrioritizedPrimaryField.Name {
    					t.Errorf("schema %v prioritized primary field should be %v, but got %v", s, field, s.PrioritizedPrimaryField.Name)
    				}
    			}
    
    			if !found {
    				t.Errorf("schema %v failed to found primary key: %v", s, field)
    			}
    		}
    	})
    }
    
    func checkSchemaField(t *testing.T, s *schema.Schema, f *schema.Field, fc func(*schema.Field)) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  7. tests/postgres_test.go

    		t.Fatalf("failed to found column log_id")
    	}
    }
    
    type Post struct {
    	ID         uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4();"`
    	Title      string
    	Categories []*Category `gorm:"Many2Many:post_categories"`
    }
    
    type Category struct {
    	ID    uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4();"`
    	Title string
    	Posts []*Post `gorm:"Many2Many:post_categories"`
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Oct 08 09:16:32 GMT 2022
    - 6.4K bytes
    - Viewed (3)
  8. schema/schema_test.go

    		Base Company `gorm:"embedded;embeddedPrefix:company_"`
    	}
    
    	cropSchema, err := schema.Parse(&Corp{}, &sync.Map{}, schema.NamingStrategy{})
    	if err != nil {
    		t.Fatalf("failed to parse embedded struct with primary key, got error %v", err)
    	}
    
    	fields := []schema.Field{
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 12.9K bytes
    - Viewed (0)
  9. README.md

    * Context, Prepared Statement Mode, DryRun Mode
    * Batch Insert, FindInBatches, Find To Map
    * SQL Builder, Upsert, Locking, Optimizer/Index/Comment Hints, NamedArg, Search/Update/Create with SQL Expr
    * Composite Primary Key
    * Auto Migrations
    * Logger
    * Extendable, flexible plugin API: Database Resolver (Multiple Databases, Read/Write Splitting) / Prometheus…
    * Every feature comes with tests
    * Developer Friendly
    
    ## Getting Started
    Plain Text
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Nov 07 02:20:06 GMT 2023
    - 1.8K bytes
    - Viewed (0)
  10. chainable_api.go

    	"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")
    func (db *DB) Model(value interface{}) (tx *DB) {
    	tx = db.getInstance()
    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)
Back to top