Search Options

Results per page
Sort
Preferred Languages
Advance

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

  1. docs_src/sql_databases/sql_app_py39/models.py

    class User(Base):
        __tablename__ = "users"
    
        id = Column(Integer, primary_key=True)
        email = Column(String, unique=True, index=True)
        hashed_password = Column(String)
        is_active = Column(Boolean, default=True)
    
        items = relationship("Item", back_populates="owner")
    
    
    class Item(Base):
        __tablename__ = "items"
    
        id = Column(Integer, primary_key=True)
        title = Column(String, index=True)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 14:35:33 GMT 2024
    - 710 bytes
    - Viewed (0)
  2. docs_src/sql_databases/sql_app/models.py

    class User(Base):
        __tablename__ = "users"
    
        id = Column(Integer, primary_key=True)
        email = Column(String, unique=True, index=True)
        hashed_password = Column(String)
        is_active = Column(Boolean, default=True)
    
        items = relationship("Item", back_populates="owner")
    
    
    class Item(Base):
        __tablename__ = "items"
    
        id = Column(Integer, primary_key=True)
        title = Column(String, index=True)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 14:35:33 GMT 2024
    - 710 bytes
    - Viewed (0)
  3. docs_src/sql_databases/sql_app_py310/models.py

    class User(Base):
        __tablename__ = "users"
    
        id = Column(Integer, primary_key=True)
        email = Column(String, unique=True, index=True)
        hashed_password = Column(String)
        is_active = Column(Boolean, default=True)
    
        items = relationship("Item", back_populates="owner")
    
    
    class Item(Base):
        __tablename__ = "items"
    
        id = Column(Integer, primary_key=True)
        title = Column(String, index=True)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 14:35:33 GMT 2024
    - 710 bytes
    - Viewed (0)
  4. schema/relationship_test.go

    		},
    	})
    }
    
    func TestMany2ManyWithMultiPrimaryKeys(t *testing.T) {
    	type Tag struct {
    		ID     uint   `gorm:"primary_key"`
    		Locale string `gorm:"primary_key"`
    		Value  string
    	}
    
    	type Blog struct {
    		ID         uint   `gorm:"primary_key"`
    		Locale     string `gorm:"primary_key"`
    		Subject    string
    		Body       string
    		Tags       []Tag `gorm:"many2many:blog_tags;"`
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  5. schema/field.go

    				}
    
    				if prefix, ok := field.TagSettings["EMBEDDEDPREFIX"]; ok && ef.DBName != "" {
    					ef.DBName = prefix + ef.DBName
    				}
    
    				if ef.PrimaryKey {
    					if !utils.CheckTruth(ef.TagSettings["PRIMARYKEY"], ef.TagSettings["PRIMARY_KEY"]) {
    						ef.PrimaryKey = false
    
    						if val, ok := ef.TagSettings["AUTOINCREMENT"]; !ok || !utils.CheckTruth(val) {
    							ef.AutoIncrement = false
    						}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 32K bytes
    - Viewed (1)
  6. tests/migrate_test.go

    		return
    	}
    
    	type UniqueTest struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique"`
    	}
    
    	type UniqueTest2 struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique;default:NULL"`
    	}
    
    	type UniqueTest3 struct {
    		ID   string `gorm:"primary_key"`
    		Name string `gorm:"unique;default:''"`
    	}
    
    	type UniqueTest4 struct {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  7. tests/update_test.go

    	Name  string
    	Token Token `gorm:"foreignKey:UserID"`
    }
    
    func (t *TokenOwner) BeforeSave(tx *gorm.DB) error {
    	t.Name += "_name"
    	return nil
    }
    
    type Token struct {
    	UserID  int    `gorm:"primary_key"`
    	Content string `gorm:"type:varchar(100)"`
    }
    
    func (t *Token) BeforeSave(tx *gorm.DB) error {
    	t.Content += "_encrypted"
    	return nil
    }
    
    func TestSaveWithHooks(t *testing.T) {
    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)
  8. tests/query_test.go

    	}
    
    	AssertEqual(t, p, p2)
    }
    
    func TestStringPrimaryKeyForNumericValueStartingWithZero(t *testing.T) {
    	type AddressByZipCode struct {
    		ZipCode string `gorm:"primary_key"`
    		Address string
    	}
    
    	DB.Migrator().DropTable(&AddressByZipCode{})
    	if err := DB.AutoMigrate(&AddressByZipCode{}); err != nil {
    		t.Fatalf("failed to migrate, got error %v", err)
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
  9. schema/relationship.go

    	} else {
    		primarySchemaName := primarySchema.Name
    		if primarySchemaName == "" {
    			primarySchemaName = relation.FieldSchema.Name
    		}
    
    		if len(relation.primaryKeys) > 0 {
    			for _, primaryKey := range relation.primaryKeys {
    				if f := primarySchema.LookUpField(primaryKey); f != nil {
    					primaryFields = append(primaryFields, f)
    				}
    			}
    		} else {
    			primaryFields = primarySchema.PrimaryFields
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  10. migrator/migrator.go

    				createTableSQL += "PRIMARY KEY ?,"
    				primaryKeys := make([]interface{}, 0, len(stmt.Schema.PrimaryFields))
    				for _, field := range stmt.Schema.PrimaryFields {
    					primaryKeys = append(primaryKeys, clause.Column{Name: field.DBName})
    				}
    
    				values = append(values, primaryKeys)
    			}
    
    			for _, idx := range stmt.Schema.ParseIndexes() {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
Back to top