Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 20 for and (1.2 sec)

  1. tests/group_by_test.go

    		t.Errorf("name should be groupby, total should be 660, but got %+v", result)
    	}
    
    	var active bool
    	if err := DB.Model(&User{}).Select("name, active, sum(age)").Where("name = ? and active = ?", "groupby", true).Group("name").Group("active").Row().Scan(&name, &active, &total); err != nil {
    		t.Errorf("no error should happen, but got %v", err)
    	}
    
    	if name != "groupby" || active != true || total != 40 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 3.3K bytes
    - Viewed (0)
  2. clause/where_test.go

    			}},
    			"SELECT * FROM `users` WHERE (`users`.`id` <> ? AND `age` <= ?) OR `name` <> ? AND (`score` <= ? OR `name` LIKE ?)",
    			[]interface{}{"1", 18, "jinzhu", 100, "%linus%"},
    		},
    		{
    			[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
    				Exprs: []clause.Expression{clause.And(clause.Eq{Column: "age", Value: 18}, clause.Or(clause.Neq{Column: "name", Value: "jinzhu"}))},
    			}},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  3. schema/index_test.go

    		FieldF1 string `gorm:"uniqueIndex:uniq_field_f1_f2;index"` // mul uniqueIndex and index
    		FieldF2 string `gorm:"uniqueIndex:uniq_field_f1_f2;"`
    
    		FieldG string `gorm:"unique;uniqueIndex"` // unique and uniqueIndex
    
    		FieldH1 string `gorm:"unique;uniqueIndex:uniq_field_h1_h2"` // unique and mul uniqueIndex
    		FieldH2 string `gorm:"uniqueIndex:uniq_field_h1_h2"`        // unique and mul uniqueIndex
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 8K bytes
    - Viewed (0)
  4. clause/group_by_test.go

    			}, clause.GroupBy{
    				Columns: []clause.Column{{Name: "gender"}},
    				Having:  []clause.Expression{clause.Neq{"gender", "U"}},
    			}},
    			"SELECT * FROM `users` GROUP BY `role`,`gender` HAVING `role` = ? AND `gender` <> ?",
    			[]interface{}{"admin", "U"},
    		},
    	}
    
    	for idx, result := range results {
    		t.Run(fmt.Sprintf("case #%v", idx), func(t *testing.T) {
    			checkBuildClauses(t, result.Clauses, result.Result, result.Vars)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  5. prepare_stmt.go

    	// suppose the maxopen is 1, g1 is creating record and g2 is querying record.
    	// 1. g1 begin tx, g1 is requeue because of waiting for the system call, now `db.ConnPool` db.numOpen == 1.
    	// 2. g2 select lock `conn.PrepareContext(ctx, query)`, now db.numOpen == db.maxOpen , wait for release.
    	// 3. g1 tx exec insert, wait for unlock `conn.PrepareContext(ctx, query)` to finish tx and release.
    	stmt, err := conn.PrepareContext(ctx, query)
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 28 08:47:39 GMT 2024
    - 6.4K bytes
    - Viewed (0)
  6. schema/index.go

    package schema
    
    import (
    	"fmt"
    	"sort"
    	"strconv"
    	"strings"
    )
    
    type Index struct {
    	Name    string
    	Class   string // UNIQUE | FULLTEXT | SPATIAL
    	Type    string // btree, hash, gist, spgist, gin, and brin
    	Where   string
    	Comment string
    	Option  string        // WITH PARSER parser_name
    	Fields  []IndexOption // Note: IndexOption's Field maybe the same
    }
    
    type IndexOption struct {
    	*Field
    	Expression string
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 3.7K bytes
    - Viewed (0)
  7. tests/serializer_test.go

    	}
    
    	if err := DB.Create(&data).Error; err != nil {
    		t.Fatalf("failed to create data, got error %v", err)
    	}
    
    	var result SerializerStruct
    	if err := DB.Where("roles2 IS NULL AND roles3 = ?", "").First(&result, data.ID).Error; err != nil {
    		t.Fatalf("failed to query data, got error %v", err)
    	}
    
    	AssertEqual(t, result, data)
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 21 14:09:38 GMT 2023
    - 7.6K bytes
    - Viewed (0)
  8. tests/associations_belongs_to_test.go

    		t.Errorf("Error happened when append company to user, got %v", err)
    	}
    
    	if users[0].CompanyID == nil || users[1].CompanyID == nil || *users[0].CompanyID != *users[1].CompanyID {
    		t.Errorf("user's company id should exists and equal, but its: %v, %v", users[0].CompanyID, users[1].CompanyID)
    	}
    
    	DB.Model(&users[0]).Association("Company").Delete(&company)
    	AssertAssociationCount(t, users[0], "Company", 0, "After Delete")
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
  9. clause/expression_test.go

    		ExpectedVars: []interface{}{"jinzhu", "jinzhu2", "jinzhu"},
    	}, {
    		SQL:          "@@test AND name1 = @name1 AND name2 = @name2 AND name3 = @name1 @notexist",
    		Vars:         []interface{}{sql.Named("name1", "jinzhu"), sql.Named("name2", "jinzhu2")},
    		Result:       "@@test AND name1 = ? AND name2 = ? AND name3 = ? @notexist",
    		ExpectedVars: []interface{}{"jinzhu", "jinzhu2", "jinzhu"},
    	}, {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Aug 10 05:34:33 GMT 2023
    - 8.4K bytes
    - Viewed (0)
  10. clause/where.go

    	}
    
    	clause.Expression = where
    }
    
    func And(exprs ...Expression) Expression {
    	if len(exprs) == 0 {
    		return nil
    	}
    
    	if len(exprs) == 1 {
    		if _, ok := exprs[0].(OrConditions); !ok {
    			return exprs[0]
    		}
    	}
    
    	return AndConditions{Exprs: exprs}
    }
    
    type AndConditions struct {
    	Exprs []Expression
    }
    
    func (and AndConditions) Build(builder Builder) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 5.1K bytes
    - Viewed (0)
Back to top