Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 13 for Condition (0.26 sec)

  1. tests/upsert_test.go

    		Name string `gorm:"column:name"`
    	}
    	user := User{ID: 1, Name: "king"}
    	tx := DB.Session(&gorm.Session{DryRun: true}).Save(&user)
    
    	if err := tx.Error; err != nil {
    		t.Fatalf("failed to update user,missing where condition,err=%+v", err)
    	}
    
    	if !regexp.MustCompile("WHERE .id. = [^ ]+$").MatchString(tx.Statement.SQL.String()) {
    		t.Fatalf("invalid updating SQL, got %v", tx.Statement.SQL.String())
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  2. chainable_api.go

    //
    // [docs]: https://gorm.io/docs/query.html#Conditions
    func (db *DB) Where(query interface{}, args ...interface{}) (tx *DB) {
    	tx = db.getInstance()
    	if conds := tx.Statement.BuildCondition(query, args...); len(conds) > 0 {
    		tx.Statement.AddClause(clause.Where{Exprs: conds})
    	}
    	return
    }
    
    // Not add NOT conditions
    //
    // Not works similarly to where, and has the same syntax.
    //
    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)
  3. tests/joins_test.go

    	DB.Joins("inner join pets on pets.user_id = users.id AND pets.name = ?", user.Pets[0].Name).Where("users.name = ?", user.Name).First(&users2)
    	if len(users2) != 1 {
    		t.Errorf("should find one users using left join with conditions, but got %v", len(users2))
    	}
    
    	var users3 []User
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  4. tests/associations_has_many_test.go

    		t.Fatalf("should only find one pets, but got %v", count)
    	}
    
    	if count := DB.Model(&user).Where("name = ?", "not found").Association("Pets").Count(); count != 0 {
    		t.Fatalf("should only find no pet with invalid conditions, but got %v", count)
    	}
    
    	// Count
    	AssertAssociationCount(t, user, "Pets", 2, "")
    
    	// Append
    	pet := Pet{Name: "pet-has-many-append"}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  5. finisher_api.go

    	tx = db.getInstance()
    	tx.Statement.Dest = values
    	tx.Statement.SkipHooks = true
    	return tx.callbacks.Update().Execute(tx)
    }
    
    // Delete deletes value matching given conditions. If value contains primary key it is included in the conditions. If
    // value includes a deleted_at field, then Delete performs a soft delete instead by setting deleted_at with the current
    // time if null.
    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)
  6. errors.go

    	// ErrNotImplemented not implemented
    	ErrNotImplemented = errors.New("not implemented")
    	// ErrMissingWhereClause missing where clause
    	ErrMissingWhereClause = errors.New("WHERE conditions required")
    	// ErrUnsupportedRelation unsupported relations
    	ErrUnsupportedRelation = errors.New("unsupported relations")
    	// ErrPrimaryKeyRequired primary keys required
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 02:53:17 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  7. statement_test.go

    			})
    
    			if reflect.DeepEqual(s1.Clauses["WHERE"], s2.Clauses["WHERE"]) {
    				t.Errorf("Where conditions should be different")
    			}
    		})
    	}
    }
    
    func TestNilCondition(t *testing.T) {
    	s := new(Statement)
    	if len(s.BuildCondition(nil)) != 0 {
    		t.Errorf("Nil condition should be empty")
    	}
    }
    
    func TestNameMatcher(t *testing.T) {
    	for k, v := range map[string][]string{
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Dec 23 13:19:41 GMT 2023
    - 1.9K bytes
    - Viewed (0)
  8. statement.go

    				// looks like a where condition
    				return []clause.Expression{clause.Expr{SQL: s, Vars: args}}
    			}
    
    			if len(args) > 0 && strings.Contains(s, "@") {
    				// looks like a named query
    				return []clause.Expression{clause.NamedExpr{SQL: s, Vars: args}}
    			}
    
    			if strings.Contains(strings.TrimSpace(s), " ") {
    				// looks like a where condition
    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)
  9. .github/labels.json

        }
      },
      "issue": {
        "with_playground": {
          "requires": 1,
          "conditions": [
            {
              "type": "descriptionMatches",
              "pattern": "/github.com\/go-gorm\/playground\/pull\/\\d\\d+/s"
            }
          ]
        },
        "critical": {
          "requires": 1,
          "conditions": [
            {
              "type": "descriptionMatches",
              "pattern": "/(critical|urgent)/i"
    Json
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 19 03:49:03 GMT 2020
    - 3.8K bytes
    - Viewed (0)
  10. tests/query_test.go

    		t.Fatalf("Build NOT condition, but got %v", result.Statement.SQL.String())
    	}
    
    	result = dryDB.Where("name = ?", "jinzhu1").Not("name = ?", "jinzhu2").Find(&User{})
    	if !regexp.MustCompile("SELECT \\* FROM .*users.* WHERE .*name.* = .+ AND NOT.*name.* = .+").MatchString(result.Statement.SQL.String()) {
    		t.Fatalf("Build NOT condition, but got %v", result.Statement.SQL.String())
    	}
    
    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)
Back to top