Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for Distinct (0.17 sec)

  1. tests/distinct_test.go

    	var names []string
    	DB.Table("users").Where("name like ?", "distinct%").Order("name").Pluck("name", &names)
    	AssertEqual(t, names, []string{"distinct", "distinct", "distinct", "distinct-2", "distinct-3"})
    
    	var names1 []string
    	DB.Model(&User{}).Where("name like ?", "distinct%").Distinct().Order("name").Pluck("Name", &names1)
    
    	AssertEqual(t, names1, []string{"distinct", "distinct-2", "distinct-3"})
    
    	var names2 []string
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2.5K bytes
    - Viewed (0)
  2. tests/count_test.go

    		t.Fatalf("Build count with select, but got %v", result.Statement.SQL.String())
    	}
    
    	result = dryDB.Table("users").Distinct("name").Count(&count)
    	if !regexp.MustCompile(`SELECT COUNT\(DISTINCT\(.name.\)\) FROM .*users.*`).MatchString(result.Statement.SQL.String()) {
    		t.Fatalf("Build count with select, but got %v", result.Statement.SQL.String())
    	}
    
    	var count4 int64
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  3. chainable_api.go

    		tx.Statement.Table = ""
    	}
    	return
    }
    
    // Distinct specify distinct fields that you want querying
    //
    //	// Select distinct names of users
    //	db.Distinct("name").Find(&results)
    //	// Select distinct name/age pairs from users
    //	db.Distinct("name", "age").Find(&results)
    func (db *DB) Distinct(args ...interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Distinct = true
    	if len(args) > 0 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  4. clause/select.go

    package clause
    
    // Select select attrs when querying, updating, creating
    type Select struct {
    	Distinct   bool
    	Columns    []Column
    	Expression Expression
    }
    
    func (s Select) Name() string {
    	return "SELECT"
    }
    
    func (s Select) Build(builder Builder) {
    	if len(s.Columns) > 0 {
    		if s.Distinct {
    			builder.WriteString("DISTINCT ")
    		}
    
    		for idx, column := range s.Columns {
    			if idx > 0 {
    				builder.WriteByte(',')
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jul 14 07:51:24 GMT 2021
    - 1.1K bytes
    - Viewed (0)
  5. callbacks/query.go

    		for _, c := range db.Statement.Schema.QueryClauses {
    			db.Statement.AddClause(c)
    		}
    	}
    
    	if db.Statement.SQL.Len() == 0 {
    		db.Statement.SQL.Grow(100)
    		clauseSelect := clause.Select{Distinct: db.Statement.Distinct}
    
    		if db.Statement.ReflectValue.Kind() == reflect.Struct && db.Statement.ReflectValue.Type() == db.Statement.Schema.ModelType {
    			var conds []clause.Expression
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Jan 29 03:34:57 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  6. finisher_api.go

    				if tx.Statement.Parse(tx.Statement.Model) == nil {
    					if f := tx.Statement.Schema.LookUpField(dbName); f != nil {
    						dbName = f.DBName
    					}
    				}
    
    				if tx.Statement.Distinct {
    					expr = clause.Expr{SQL: "COUNT(DISTINCT(?))", Vars: []interface{}{clause.Column{Name: dbName}}}
    				} else if dbName != "*" {
    					expr = clause.Expr{SQL: "COUNT(?)", Vars: []interface{}{clause.Column{Name: dbName}}}
    				}
    			}
    		}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
  7. statement.go

    		Model:                stmt.Model,
    		Unscoped:             stmt.Unscoped,
    		Dest:                 stmt.Dest,
    		ReflectValue:         stmt.ReflectValue,
    		Clauses:              map[string]clause.Clause{},
    		Distinct:             stmt.Distinct,
    		Selects:              stmt.Selects,
    		Omits:                stmt.Omits,
    		Preloads:             map[string][]interface{}{},
    		ConnPool:             stmt.ConnPool,
    		Schema:               stmt.Schema,
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
Back to top