Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 27 for courant (0.24 sec)

  1. tests/distinct_test.go

    	}
    
    	var count int64
    	if err := DB.Model(&User{}).Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 5 {
    		t.Errorf("failed to query users count, got error: %v, count: %v", err, count)
    	}
    
    	if err := DB.Model(&User{}).Distinct("name").Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 3 {
    		t.Errorf("failed to query users count, got error: %v, count %v", err, count)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2.5K bytes
    - Viewed (0)
  2. migrator/migrator.go

    func (m Migrator) HasTable(value interface{}) bool {
    	var count int64
    
    	m.RunWithValue(value, func(stmt *gorm.Statement) error {
    		currentDatabase := m.DB.Migrator().CurrentDatabase()
    		return m.DB.Raw("SELECT count(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ? AND table_type = ?", currentDatabase, stmt.Table, "BASE TABLE").Row().Scan(&count)
    	})
    
    	return count > 0
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  3. schema/schema_helper_test.go

    			if len(relations.Relations) != len(rs.Relations) {
    				t.Errorf("schema relations count don't match, expects %d, got %d", len(rs.Relations), len(relations.Relations))
    			}
    			if len(relations.EmbeddedRelations) != len(rs.EmbeddedRelations) {
    				t.Errorf("schema embedded relations count don't match, expects %d, got %d", len(rs.EmbeddedRelations), len(relations.EmbeddedRelations))
    			}
    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)
  4. chainable_api.go

    			clause.Expression = nil
    			tx.Statement.Clauses["SELECT"] = clause
    		}
    	case string:
    		if strings.Count(v, "?") >= len(args) && len(args) > 0 {
    			tx.Statement.AddClause(clause.Select{
    				Distinct:   db.Statement.Distinct,
    				Expression: clause.Expr{SQL: v, Vars: args},
    			})
    		} else if strings.Count(v, "@") > 0 && len(args) > 0 {
    			tx.Statement.AddClause(clause.Select{
    				Distinct:   db.Statement.Distinct,
    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)
  5. tests/main_test.go

    		t.Errorf("Should got error with invalid SQL")
    	}
    
    	var count1, count2 int64
    	DB.Model(&User{}).Count(&count1)
    	if count1 <= 0 {
    		t.Errorf("Should find some users")
    	}
    
    	if DB.Where("name = ?", "jinzhu; delete * from users").First(&User{}).Error == nil {
    		t.Errorf("Should got error with invalid SQL")
    	}
    
    	DB.Model(&User{}).Count(&count2)
    	if count1 != count2 {
    		t.Errorf("No user should not be deleted by invalid SQL")
    	}
    }
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Mar 24 01:31:58 GMT 2022
    - 1.4K bytes
    - Viewed (0)
  6. errors.go

    	ErrInvalidValueOfLength = errors.New("invalid association values, length doesn't match")
    	// ErrPreloadNotAllowed preload is not allowed when count is used
    	ErrPreloadNotAllowed = errors.New("preload is not allowed when count is used")
    	// ErrDuplicatedKey occurs when there is a unique key constraint violation
    	ErrDuplicatedKey = errors.New("duplicated key not allowed")
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 02:53:17 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  7. finisher_api.go

    	}
    
    	if len(tx.Statement.Selects) == 0 {
    		tx.Statement.AddClause(clause.Select{Expression: clause.Expr{SQL: "count(*)"}})
    	} else if !strings.HasPrefix(strings.TrimSpace(strings.ToLower(tx.Statement.Selects[0])), "count(") {
    		expr := clause.Expr{SQL: "count(*)"}
    
    		if len(tx.Statement.Selects) == 1 {
    			dbName := tx.Statement.Selects[0]
    			fields := strings.FieldsFunc(dbName, utils.IsValidDBNameChar)
    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)
  8. tests/customize_field_test.go

    	}
    
    	DB.Migrator().DropTable(&CustomizeColumn{})
    	DB.AutoMigrate(&CustomizeColumn{})
    
    	expected := "foo"
    	now := time.Now()
    	cc := CustomizeColumn{ID: 666, Name: expected, Date: &now}
    
    	if count := DB.Create(&cc).RowsAffected; count != 1 {
    		t.Error("There should be one record be affected when create record")
    	}
    
    	var cc1 CustomizeColumn
    	DB.First(&cc1, "mapped_name = ?", "foo")
    
    	if cc1.Name != expected {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Sep 11 09:33:31 GMT 2020
    - 6.9K bytes
    - Viewed (0)
  9. tests/migrate_test.go

    	if err := DB.Migrator().CreateView("users_pets", gorm.ViewOption{Query: query}); err != nil {
    		t.Fatalf("Failed to crate view, got %v", err)
    	}
    
    	var count int64
    	if err := DB.Table("users_pets").Count(&count).Error; err != nil {
    		t.Fatalf("should found created view")
    	}
    
    	if err := DB.Migrator().DropView("users_pets"); err != nil {
    		t.Fatalf("Failed to drop view, got %v", err)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
  10. tests/associations_has_one_test.go

    		*GetUser("slice-hasone-3", Config{Account: true}),
    	}
    
    	DB.Create(&users)
    
    	// Count
    	AssertAssociationCount(t, users, "Account", 2, "")
    
    	// Find
    	var accounts []Account
    	if DB.Model(&users).Association("Account").Find(&accounts); len(accounts) != 2 {
    		t.Errorf("accounts count should be %v, but got %v", 3, len(accounts))
    	}
    
    	// Append
    	DB.Model(&users).Association("Account").Append(
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
Back to top