Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for HasColumn (0.05 sec)

  1. tests/embedded_struct_test.go

    		t.Fatalf("failed to auto migrate, got error: %v", err)
    	}
    
    	for _, name := range []string{"author_id", "author_name", "author_email"} {
    		if !DB.Migrator().HasColumn(&EngadgetPost{}, name) {
    			t.Errorf("should has prefixed column %v", name)
    		}
    	}
    
    	stmt := gorm.Statement{DB: DB}
    	if err := stmt.Parse(&EngadgetPost{}); err != nil {
    		t.Fatalf("failed to parse embedded struct")
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed May 08 04:07:58 UTC 2024
    - 7.3K bytes
    - Viewed (0)
  2. tests/migrate_test.go

    	}
    
    	if !DB.Table("column_structs").Migrator().HasColumn(&NewColumnStruct{}, "NewName") {
    		t.Fatalf("Failed to find added column")
    	}
    
    	if err := DB.Table("column_structs").Migrator().DropColumn(&NewColumnStruct{}, "NewName"); err != nil {
    		t.Fatalf("Failed to add column, got %v", err)
    	}
    
    	if DB.Table("column_structs").Migrator().HasColumn(&NewColumnStruct{}, "NewName") {
    		t.Fatalf("Found deleted column")
    	}
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Mar 18 11:24:16 UTC 2024
    - 56.2K bytes
    - Viewed (0)
  3. migrator/migrator.go

    				).Error
    
    			}
    		}
    		return fmt.Errorf("failed to look up field with name: %s", field)
    	})
    }
    
    // HasColumn check has column `field` for value or not
    func (m Migrator) HasColumn(value interface{}, field string) bool {
    	var count int64
    	m.RunWithValue(value, func(stmt *gorm.Statement) error {
    		currentDatabase := m.DB.Migrator().CurrentDatabase()
    		name := field
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Apr 26 07:15:49 UTC 2024
    - 29K bytes
    - Viewed (0)
Back to top